|
|
|
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 -----
| <?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>Stuff by tedd</title>
</head>
<body>
<h1>tedd's session stuff (page 1)</h1>
<hr>
<h3>PHPSESSID = <?php echo session_id(); ?></h3>
<hr>
<h2>Click the next page and see numbr of visits during this visit.</h2>
<a href="session2.php?<?php echo( SID ); ?>">Next page</a>
</body>
</html> | |
--- copy below and save as session2.php -----
| <?php
session_start();
($_SESSION['count']) ? $_SESSION['count']++ : $_SESSION['count'] = 1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>Stuff by tedd</title>
</head>
<body>
<h1>tedd's session stuff (page 2)</h1>
<hr>
<h3>PHPSESSID = <?php echo session_id(); ?></h3>
<hr>
<h2>You have been here <?php echo( $_SESSION['count'] ); ?> times in this session.</h2>
<a href="session1.php?<?php echo( SID ); ?>">Previous page</a>
</body>
</html>
</html> | | |
|
| A beginner's session handling class Categories : PHP, PHP Classes, Sessions, Beginner Guides | | | session out Timer Categories : PHP, Sessions, Security, Beginner Guides | | | Basic Authentication with sessions Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions | | | Introduction to Language Files Categories : PHP, Filesystem, Beginner Guides | | | email new items in db Categories : PHP, Email, Databases, MySQL, Beginner Guides | | | XDT Topsite (Gold v1.0) Categories : Databases, CSS, PHP, HTML and PHP, Sessions | | | Problem passing session variables Categories : Sessions, PHP | | | Newbie Notes #8 - A cron trick Categories : PHP, CURL, Beginner Guides | | | Get the self URL of current page Categories : PHP, URLs, Beginner Guides | | | A very simple PHP single password cookie based login without usernames. Categories : PHP, Cookies, Security, Beginner Guides | | | Demo of Alternate Pagination Paradigm (Paging) Categories : PHP, User Interface, Sessions | | | PHP Email image generator - hide your email from bots - using the GD Library Categories : PHP, Graphics, GD image library, Beginner Guides | | | Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides | | | Easy alert box pop-up function Categories : PHP, Java Script, Beginner Guides | | | How to update selected fields only Categories : PHP, Databases, Beginner Guides | |
|
|
|