Well, I used session_start () on the top of the page:
Listing of firstpage.php
PHP Code:
<?php session_start (); ?>
<HTML>
<BODY>
<FORM METHOD="POST" ACTION="secondpage.php?<?php print SID ?>">
<INPUT TYPE="text" NAME="username">
<INPUT TYPE="text" NAME="age">
<INPUT TYPE="submit" VALUE="GO!">
</BODY>
</HTML>
Listing of secondpage.php
PHP Code:
<?php
session_start ();
// ...
// ...
if (isset ($_SESSION['username'])
print "User name is " . $_SESSION['username'];
if (isset ($_SESSION['age'])
print "User age is " . $_SESSION['age'];
?>
The above code does not work. I pass the session ID as a query string when I link to the other page so this code is supposed to work, but I get only a blank output.
The PHP manual says that session_register () functions are deprecated or outdated and I'm asked to use only $_SESSION for accessing session state variables. How do I get around this problem?