Image Image Image Image Image Image Image Image Image Image

Technology Blog | JasonSlater.co.uk Technology News | June 20, 2013

Scroll to top

Top

No Comments

PHP: Session Variables

Session variables used to need registering however now they are more in line with _POST variables, so:

On the page to activate Session Handling use

session_start();

You can always check the Session is working by obtaining the Session ID using

session_id();

Now variables can be registered and used using the form

$_SESSION['variable'] = "value";

Removal of a session variable can be performed using

session_unset( $_SESSION['variable'] );

Alternatively just calling session_unset(); would remove all session variables but maintain the session ID.

To finally close the session use

session_destroy();

Tags

Submit a Comment