Code: Select all
<?php
//first_page.php
session_start();
print("<html><pre>");
$_SESSION["MyLogin"] = "FYICenter";
print("A value saved in the session named as MyLogin.\n");
$_SESSION["MyColor"] = "Blue";
print("A value saved in the session named as MyColor.\n");
print("Click <a href=next_page.php>Next Page</a>"
." to retrieve the values.\n");
print("</pre></html>\n");
?>Code: Select all
<?php
//next_page.php
session_start();
print("<html><pre>");
$myLogin = $_SESSION["MyLogin"];
print("Value of MyLogin has been retrieved: ".$myLogin."\n");
$myColor = $_SESSION["MyColor"];
print("Value of MyColor has been retrieved: ".$myColor."\n");
print('</pre><a href="first_page.php">Click here to go back</a></html>\n');
?>Code: Select all
Value of MyLogin has been retrieved:
Value of MyColor has been retrieved:
Click here to go back\nSo my question is, what could be preventing my sessions from working? Also, when I click on the next_page.php link, it transfers a ?PHPSESSID variable in the URL. Maybe this has something to do with the problem? I don't know. Any help will be appreciated. Thanks!