chitika Ad

Saturday, 1 March 2014

Zend Framework 101: Zend_Session

Zend Framework 101: Zend_Session

Removing Session Data

To remove a value from a session, use PHP's unset() function on the object property. This is demonstrated in Listing 5.
Listing 5 Removing a value from a session namespace (listing-5.php)
<?php
    require_once('Zend/Session.php');
 
    $session = new Zend_Session_Namespace('identity');
    unset($session->username);
?>
In some cases you might want to remove all data in a namespace. You can do this either by looping over all values in the namespace and calling unset() on each one, or you can use theZend_Session::namespaceUnset(). This method accepts the name of the namespace as its only argument, as demonstrated in Listing 6.
Listing 6 Removing an entire namespace from a session (listing-6.php)
<?php
    require_once('Zend/Session.php');
 
    Zend_Session::namespaceUnset('identity');
?>
You can destroy the entire current session using the Zend_Session::destroy() static function.

No comments:

Post a Comment