MDL-10689:
[moodle-linuxchix.git] / lib / session-test.php
blob32aa7b91de4cb4f4d0668df3edee3eb1cfdc1a59
1 <?php
2 /// This is a tiny standalone diagnostic script to test that sessions
3 /// are working correctly on a given server.
4 ///
5 /// Just run it from a browser. The first time you run it will
6 /// set a new variable, and after that it will try to find it again.
7 /// The random number is just to prevent browser caching.
9 session_start();
11 if (!isset($_SESSION["test"])) { // First time you call it.
12 echo "<p>No session found - starting a session now.";
13 $_SESSION["test"] = "welcome back!";
15 } else { // Subsequent times you call it
16 echo "<p>Session found - ".$_SESSION["test"];
17 echo "</p><p>Sessions are working correctly</p>";
20 echo "<p><a href=\"session-test.php?random=".rand(1,10000)."\">Reload this page</a></p>";