Wednesday, March 26, 2008

PHP SESSION HANDLING EXAMPLE

The below code is a very simple example of Session.
Please note that the "session_start" statement *must* be the first line of your code.
To see the example at work, please review:

http://www.xn--ovg.com/session

tedd


--- copy below and save as session1.php -----
session_start();
?>

"http://www.w3.org/TR/html4/strict.dtd">



Stuff by tedd




Anand's session stuff (page 1)




PHPSESSID =




Click the next page and see numbr of visits during this visit.


Next page




--- copy below and save as session2.php -----

session_start();
($_SESSION['count']) ? $_SESSION['count']++ : $_SESSION['count'] = 1;
?>

"http://www.w3.org/TR/html4/strict.dtd">



Stuff by tedd



Anand's session stuff (page 2)




PHPSESSID =




You have been here times in this session.


Previous page


No comments: