Re: session doesn't work.
| From: | Justin French | Date: | Thu, 22 May 2003 02:34:59 +0000 |
| Subject: | Re: session doesn't work. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148496@lists.php.net to get a copy of this message | ||
on 22/05/03 2:08 PM, Meay Santiglia (meay0505@yahoo.com) wrote:
> When I run it, nothing is dispalyed.
> I have changed php.ini file, session.auto_start=0 to
> 1.
> and my cookies are enabled.
session.auto_start=0 only means (i think) that you don't have to call
session_start() at the top of your scripts... so that's not your problem.
Read this note made on http://php.net/session :
"Note: Please note when working with sessions that a record of a session is
not created until a variable has been registered using the
session_register() function or by adding a new key to the $_SESSION
superglobal array. This holds true regardless of if a session has been
started using the session_start() function. "
So, change your code to either:
PHP >= 4.1
<?php
session_start();
$_SESSION['test'] = 'something';
?>
<html><head><title>starting or resuming a
session</title>
</head><body>
<?php
print "<p>Your session ID is ".session_id()."</p>\n\n";
print "<p>The value of the session var 'test' is
".$_SESSION['test']."</p>\n\n";
?>
</body></html>
OR PHP < 4.1
<?php
session_start();
$test = "something";
session_register("test");
?>
<html><head><title>starting or resuming a
session</title>
</head><body>
<?php
print "<p>Your session ID is ".session_id()."</p>\n\n";
?>
</body></html>
Justin