note 25056 rejected from ref.session by jmcastagnetto

From: Date: Tue, 10 Sep 2002 19:12:09 +0000
Subject: note 25056 rejected from ref.session by jmcastagnetto
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-36472@lists.php.net to get a copy of this message
Here are some considerations about sessions, using apache 1.3.26 and PHP 4.0.6: Calling SID directly as in <?=SID?> or <?php echo SID?> doesn't work. You must use session_id function (see end of the following code). Here's a HTML-PHP example on how to do it: <?php session_start(); //You must start the session BEFORE sending any HTML headers. ?> <html> <head> <title>Testing sessions with apache 1.3.26 and PHP 4.0.6</title> </head> <body bgcolor="#FFFFFF"> <?php if (!(isset($_SESSION['count']))) { $_SESSION['count']=0; } else { $_SESSION['count']++; } /* Note that you must explicitly define a variable to handle the count value. Just using $count directly won't work...*/ $count = $_SESSION['count']; echo "You visited this page $count times."; ?> <font face="verdana">SESSION ID = <?php echo session_id();?></font> </body> </html> Hope this helps. Er Galvão Abbott

« previous php.notes (#36472) next »