You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

  1. <html>
  2. <body bgcolor="white">
  3. <head>
  4. <title>Sessions Example</title>
  5. </head>
  6. <body>
  7. <h3>Sessions Example</h3>
  8. <?php
  9. // print session info
  10. $session = $request->session;
  11. $created = new Java("java.util.Date", $session->creationTime);
  12. $accessed = new Java("java.util.Date", $session->lastAccessedTime);
  13. print "Session ID: $session->id<br>\n";
  14. print "Created: " . $created->toString() . "<br>\n";
  15. print "Last Accessed: " . $accessed->toString() . "<br>\n";
  16. // set session info if needed
  17. if ($dataName) $session->setAttribute($dataName, $dataValue);
  18. // print session contents
  19. print "<P>\n";
  20. print "The following data is in your session:<br>\n";
  21. $e = $session->attributeNames;
  22. while ($e->hasMoreElements()) {
  23. $name = $e->nextElement();
  24. $value = $session->getAttribute($name);
  25. print "$name = $value<br>\n";
  26. }
  27. ?>
  28. <P>
  29. <form action="<?php echo $PHP_SELF ?>" method=POST>
  30. Name of Session Attribute:
  31. <input type=text size=20 name=dataName>
  32. <br>
  33. Value of Session Attribute:
  34. <input type=text size=20 name=dataValue>
  35. <br>
  36. <input type=submit>
  37. </form>
  38. <P>GET based form:<br>
  39. <form action="<?php echo $PHP_SELF ?>" method=GET>
  40. Name of Session Attribute:
  41. <input type=text size=20 name=dataName>
  42. <br>
  43. Value of Session Attribute:
  44. <input type=text size=20 name=dataValue>
  45. <br>
  46. <input type=submit>
  47. </form>
  48. <p><a href="<?php echo $PHP_SELF ?>?dataName=foo&dataValue=bar" >URL encoded </a>
  49. </body>
  50. </html>
  51. </body>
  52. </html>