RE: [PHP] problem using SESSION
| From: | Christensen, BruceX R | Date: | Wed, 09 Aug 2000 19:52:30 +0000 |
| Subject: | RE: [PHP] problem using SESSION | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-10987@lists.php.net to get a copy of this message | ||
Here's what I would do:
session_start();
$sess = &$GLOBALS[HTTP_SESSION_VARS];
if (!isset($sess[count])) {
$sess[count] = 0;
echo "<li>Counter initialized, please reload this page to see it
increment";
} else {
echo "<li>Waking up session $PHPSESSID";
$sess[count]++;
}
echo "<li>The counter is now $sess[count] ";
--Bruce
Bruce Christensen
Intel Corporation
brucex.r.christensen@intel.com
-----Original Message-----
From: Peter Hicks [mailto:phicks@smartpartner.com]
Sent: Wednesday, August 09, 2000 12:33 PM
To: php-general@lists.php.net
Subject: [PHP] problem using SESSION
Hello List,
I have recently installed php4 and I am experementing with sessions.
I have a page containing the following code:
<?
session_start();
session_register("SESSION");
if (! isset($SESSION)) {
$SESSION["count"] = 0;
echo "<li>Counter initialized, please reload this page to see it
increment";
} else {
echo "<li>Waking up session $PHPSESSID";
$SESSION["count"]++;
}
echo "<li>The counter is now $SESSION[count] ";
?>
However, when I view this page I get the following error:
Warning: Cannot send session cookie - headers already sent by
(output started at /usr/local/apache/htdocs/test.php:5) in
/usr/local/apache/htdocs/test.php
on line 15
Warning: Cannot send session cache limiter - headers already sent
by (output started at /usr/local/apache/htdocs/test.php:5) in
/usr/local/apache/htdocs/test.php
on line 15
Counter initialized, please reload this
page to see it increment
The counter is now 0
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net