note 25056 added to ref.session
| From: | erabbott at NOSPAMterra dot com dot br | Date: | Mon, 09 Sep 2002 14:51:31 +0000 |
| Subject: | note 25056 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36394@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
--
http://www.php.net/manual/en/ref.session.php
http://master.php.net/manage/user-notes.php?action=edit+25056
http://master.php.net/manage/user-notes.php?action=delete+25056
http://master.php.net/manage/user-notes.php?action=reject+25056