WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder



Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Simple Session example
Categories : PHP, Beginner Guides, Sessions Click here to Update Your Picture
tedd sperling
Date : Mar 03rd 2006
Grade : 2 of 5 (graded 6 times)
Viewed : 76762
File : 4349.zip
Images : No Images for this code example.
Search : More code by tedd sperling
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

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>



session out Timer
Categories : PHP, Sessions, Security, Beginner Guides
A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
Basic Authentication with sessions
Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions
Validating a URL with preg_match
Categories : PHP, Regexps, Beginner Guides, Data Validation
Simple Cookie example
Categories : PHP, Beginner Guides, Cookies
a PHP Function to Get only the filename (remove the extension) using regular expressions.
Categories : PHP, Regexps, Beginner Guides
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
Upload Via FTP - an alternative to move_uploaded_file
Categories : PHP, FTP, Beginner Guides
How to display any array in several rows and columns of a table. Not just in one column or in alternate rows. This example shows a nice color table generated with PHP, but can be used with any array values(e.g. Database)
Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics
Prevent multi submit
Categories : PHP, Sessions
Easy alert box pop-up function
Categories : PHP, Java Script, Beginner Guides
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
How to update selected fields only
Categories : PHP, Databases, Beginner Guides
Beginners Array Functions
Categories : PHP, Beginner Guides, Arrays
 Dorival Martinez wrote :1829
Congratulations. I am a begginer in PHP and your explanation about sessions was the best that I ever read. 
Sincerely,
Dorival, from Brazil.