Re: session not working
| From: | sagar N Chand | Date: | Thu, 27 Sep 2001 12:36:11 +0000 |
| Subject: | Re: session not working | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68993@lists.php.net to get a copy of this message | ||
session must be registered before any code is sent to the browser. so the syntax should be
<?session_start();
session_register("uname");
session_register("pwd");
.................
....................
....................
?>
<HTML>
<body bgcolor="#ffffff">
html code here
/sagar
----- Original Message -----
From: Krushna Kumar R
To: php-general@lists.php.net
Sent: Thursday, September 27, 2001 5:43 PM
Subject: [PHP] session not working
Hi,
I wrote a program where the session gets created, but on subsequent page the session does not work
or i could not retrieve the value kindly help me, I have put the coding below
The operating system I use is Win98 and Personal Web Server, PHP version used is 4.0.6
File 1 : where the session is registered or created
<?session_start();?>
<HTML>
<body bgcolor="#ffffff">
<?php
session_register("uname");
session_register("pwd");
print "Username var is - ". $username."<br>";
print "Password var is - ". $password."<br>";
$uname=$username;
$pwd=$password;
print "Uname var is - ". $uname."<br>";
print "Pwd var is - ". $pwd."<br>";
echo session_is_registered("uname");
echo session_name("uname");
?>
<a href="file2.php">click here to go to next page</a>
</body>
</HTML>
File 2 : Next page, the file where i check for the session variable's value
<?session_start();
print "uname is - ".$uname."<br>";
echo "Session is - ".session_is_registered("uname")."<br>";
echo "session name is - ". session_name("uname")."<br>";
echo "the session is $uname"."<br>";
?>
<a href="last.php">click here go to last page</a>
Those are the coding i had used on the files i was trying to execute
Regards
Krushna Kumar