Session variables
| From: | Bob Sears | Date: | Thu, 17 May 2001 11:45:39 +0000 |
| Subject: | Session variables | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-7668@lists.php.net to get a copy of this message | ||
For the following code blocks:
#---------- top.php first program enteredsession_start(); session_register ('trackingnumber'); if (IsSet($trackingnumber)){ print ("Issued session destroy because trackingnumber = $trackingnumber<br>"); session_destroy(); print ("trackingnumber = $trackingnumber<br>"); } else { print ("trackingnumber has not been set<br><br>"); } print ("<html>"); print ("<head>"); print ("</head>"); print ("<body>"); print ("<h3>top.php is the entry point ...</h3>"); print ("<h3>This is the value of trackingnumber: $trackingnumber<br><br>"); print ("<a href=\"middle.php\">To middle</a>"); print ("</body>"); print ("</html>");
#---------- middle.php second program enteredsession_start(); session_register('trackingnumber'); if (!IsSet($trackingnumber)){ $mtime = explode (" ",microtime()); $mseconds = $mtime[0] * 1000000000; srand($mseconds); $trackingnumber = rand(); print ("<h3>tracking number on input is: ".$trackingnumber."<br></h3>"); print ("<h3>was reset<br><br></h3>"); } else { print ("<h3>tracking number on input is: ".$trackingnumber."<br></h3>"); print ("<h3>was not reset<br><br></h3>"); } $rnumber = 1234567; print ("trackingnumber: $trackingnumber<br>");
print ("rnumber: $rnumber<br><br>");
print ("session name: ".session_name());
print ("<br>");
print ("session id: ".session_id());
print ("<br>");
#----- check for the previous session's existance
print ("<html>");
print ("<head>");
print ("</head>");
print ("<body>");
print ("<h3>middle.php<br><br>This is the session id being passed to bottom: [");
print ("$trackingnumber");
print ("]</h3>");
print ("<a href=\"bottom.php?Session=$trackingnumber\">To bottom<br><br></a>");
print ("<a href=\"top.php\">To top</a>");
print ("</body>");
print ("</html>");
#---------- bottom.php third program enteredsession_start(); parse_str($QUERY_STRING); print $Session; print ("<html>"); print ("<head>"); print ("</head>"); print ("<body>"); print ("<h3>bottom.php<br><br>This is what was passed from middle: ["); print $Session; print ("]</h3>"); print ("<a href=\"middle.php\">Back to middle</a>"); print ("</body>"); print ("</html>"); Entering program top.php, I check whether the variable $trackingnumber has been set. If so, I want to destroy its contents. $trackingnumber should be empty upon entry to middle.php, where it gets set and passed to bottom.php. In traversing backwards, entry to top.php should empty the contents of $trackingnumber. Why doesn't the session_destroy() perform that? Bob