Your Ad Here

WorldofPHP.NET >> Sessions and Cookies

Understanding Sessions Object in PHP

Basic Introduction on using Session objects in PHP

Published Date : 30 Nov 2007

Author : hand
PHP Version : PHP 4
Platform : Linux,Windows,FreeBSD,Mac OSX,Sun Solaris
 
Views : 999
Rating : (0 votes so far)
Email to a Friend | Print this Article | Add to Favourites | Report Error

What Is a Session?

A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.

Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.

How To Turn On the Session Support?

The session support can be turned on automatically at the site level, or manually in each PHP page script:
Turning on session support automatically at the site level: Set session.auto_start = 1 in php.ini.
Turning on session support manually in each page script: Call session_start() funtion

How To Save Values to the Current Session?

When session is turned on, a session will be automatically created for you by the PHP engine. If you want to save any values to the session, you can use the pre-defined associative array called $_SESSION. The following PHP script shows you how to save values to the session:



    Other Related and Popular Articles :

    PHP security tips for upload files
    Always restrict the file types that you allow and don’t rely on a blacklist approach.
    Web Services Implementation using PHP and SOAP
    Basic Introduction on PHP , Web Services and SOAP
    Developing a Login System with PHP and MySQL
    Developing a Login System with PHP and MySQL
    PHP Form Mailer
    How to create PHP Form Mailer to stop spammer

    Author Profile : hand

    Click here to view Author Profile


    How would you rate the quality of this content?
    Poor Excellent

    Comments

    Leave New Comments


    Article Content copyright by hand
    Everything else Copyright © by WorldofPHP.NET 2008