File: session-test.php

package info (click to toggle)
moodle 1.6.3-2%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,172 kB
  • ctags: 51,688
  • sloc: php: 231,916; sql: 5,631; xml: 2,688; sh: 1,185; perl: 638; makefile: 48; pascal: 36
file content (22 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/// This is a tiny standalone diagnostic script to test that sessions 
/// are working correctly on a given server.  
///
/// Just run it from a browser.   The first time you run it will 
/// set a new variable, and after that it will try to find it again.
/// The random number is just to prevent browser caching.

session_start();

if (!isset($_SESSION["test"])) {   // First time you call it.
    echo "<p>No session found - starting a session now.";
    $_SESSION["test"] = "welcome back!";

} else {                           // Subsequent times you call it
    echo "<p>Session found - ".$_SESSION["test"];
    echo "</p><p>Sessions are working correctly</p>";
}

echo "<p><a href=\"session-test.php?random=".rand(1,10000)."\">Reload this page</a></p>";

?>