Home Tutorial Php Examples Destroying the session

 
 

Share on Google+Share on Google+
Destroying the session
Posted on: July 31, 2009 at 12:00 AM
Advertisement
In this example you will learn about destroying the session in PHP.

Destroying Session

Session_destroy() function is used for destroying all of the data associated with the current session. Neither it does not intervene any of the global variables nor the session cookie. For completely removing the session, it is usually used with session_unset() function. It returns TRUE on success or FALSE on failure.

Syntax 

bool session_decode ( string $data )

Parameters

data

Example:

<?php
session_start();
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {
echo setcookie(session_name(), '', time()-42000, '/');
}
session_destroy();
?>
 

The Output:

As the time cross over 42000 seconds, the session would getexpired and all the related data will be deleted automatically.

Advertisement

Related Tags for Destroying the session:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 31, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com