Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Sessions Not Working--Trying Again with Simplified Example
    text
    copied!<p>Since our web server was rebooted, PHP sessions are no longer working. Several people gave me helpful ideas, but none of them worked. I made a VERY simplified example that I'm pretty sure should work, but it does not work. If someone can explain why I will be very grateful. I've spent a whole day on this so far.</p> <p>My understanding is that $_SESSION is supposed to be "super global" meaning it's available anywhere.</p> <p>For clarity, I made two stripped down, rewritten pages where the code STILL doesn't work, i.e. print "Hello World".</p> <p>If someone could tell me what is wrong with THIS I would greatly appreciate it!</p> <p>----------- WEB PAGE ONE.PHP -----------------</p> <pre><code>&lt;?PHP session_start(); ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Page One&lt;/title&gt; &lt;/head&gt;&lt;body&gt; &lt;?PHP $_SESSION['testvalue'] = "Hello World"; ?&gt; &lt;p&gt;&lt;a href="pagetwo.php"&gt;Click here&lt;/a&gt; to see page two&lt;/p&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>----------- WEB PAGE TWO.PHP -----------------</p> <pre><code>&lt;?PHP session_start(); ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Page Two&lt;/title&gt; &lt;/head&gt;&lt;body&gt; &lt;?PHP echo $_SESSION['testvalue']; ?&gt; &lt;br&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>I run web page one and click the link to go to page two, and instead of a page showing "Hello World" I get</p> <p>Notice: Undefined index: testvalue in c:\inetpub\wwwroot\two.php</p> <p>I checked C:\PROGRAMDATA\PHP\SESSIONS and there is a file in there called</p> <p><strong>sess_905m06314ibdubru8ko0aqj4d1</strong></p> <p>Which contains the following</p> <p><strong>testvalue|s:11:"hello world";</strong></p> <p>This file was created when I ran <strong>one.php</strong>, indicating that the app has permission to write the session information</p> <p>Sorry if I seem dense but I'm just not understanding why this isn't working and have spent the better part of a day trying to figure it out.</p> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload