Changeset 31 for trunk

Show
Ignore:
Timestamp:
11/14/04 10:06:02 (4 years ago)
Author:
gerd
Message:

- added Restart() function and example
- changed class layout (as suggested by Stephan Schmidt)

  • all user interface functions are now implemented in the base class: patSession_Storage
  • each container must implement: _start(), _suspend()
  • optional each driver may implement event handler: _handleDestroy() and _handleFork()

- replaced "&" with "&"
- Null-Driver has now the same features as Cli-Driver

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/example_basic_count.php

    r25 r31  
    2424        $sess   =&      patSession::singleton( 'ham' ); 
    2525 
     26        if( isset( $_REQUEST['restart'] ) &&  $_REQUEST['restart'] == 'force' ) 
     27        { 
     28                $sess->destroy(); 
     29                $sess->restart(); 
     30        } 
     31         
    2632        // see wheter the started session is new 
    2733        if( $sess->isNew() ) 
     
    4147        $queryString    =       $sess->getQueryString(); 
    4248        echo '- <a href="' . $_SERVER['PHP_SELF'] . '?' . $queryString . '" title="'. $_SERVER['PHP_SELF'] . '?' . $queryString .'">Continue this session</a> <br />'; 
    43         echo '- <a href="' . $_SERVER['PHP_SELF'] . '" title="'. $_SERVER['PHP_SELF'] . '">Start over</a> <br />'; 
     49        echo '- <a href="' . $_SERVER['PHP_SELF'] . '" title="'. $_SERVER['PHP_SELF'] . '">Start over</a> (make sure, that you don\'t send cookies!) <br />'; 
     50        echo '- <a href="' . $_SERVER['PHP_SELF'] . '?restart=force" title="'. $_SERVER['PHP_SELF'] . '">Restart with cookies</a> (This will destroy the session as well!)<br />'; 
    4451?> 
  • trunk/examples/example_basic_destroy.php

    r10 r31  
    3434         
    3535        echo '...try to recieve a value from the session<br />';         
    36         $sess->get( 'fb', 'frequence modulation' ); 
     36        $sess->get( 'fb' ); 
    3737?> 
  • trunk/examples/example_test_null.php

    r22 r31  
    2222         
    2323        // most easy way to create a session object 
    24         $sess   =&      patSession::singleton( 'ham', 'Null' ); 
     24        $sess   =&      patSession::singleton( 'money', 'Null' ); 
    2525 
    26         echo "Whatever you save, it will get lost... :-)<br />\n"; 
     26        echo "Whatever you save, it will not survive the next request!<br />\n"; 
    2727         
    28         echo "Try to save 50 Euro... <br /> \n"; 
    29         $sess->set( 'save', '50,-- Euro' ); 
    30         echo "See what was saved: "; 
    31         var_dump( $sess->get( 'save' ) ); 
    32         echo "<br />\n"; 
     28        if( isset( $_REQUEST['continue'] ) &&  $_REQUEST['continue'] == 'try' ) 
     29        { 
     30                echo "See what was saved in the European bank account: "; 
     31                var_dump( $sess->get( 'account_euro' ) ); 
     32                echo "<br />\n"; 
     33                 
     34                echo "See what was saved in the Australian bank account: "; 
     35                var_dump( $sess->get( 'account_dollar' ) ); 
     36                echo "<br />\n"; 
     37        } 
     38        else 
     39        { 
     40                echo "Try to save 50 Euro in our European bank account... <br /> \n"; 
     41                $sess->set( 'account_euro', '50,-- Euro' ); 
     42                echo "Try to save 50 Dollar in our Australian bank account... <br /> \n"; 
     43                $sess->set( 'account_dollar', '$50' ); 
     44        } 
    3345         
    34         echo "Try to save 50 Dollar... <br /> \n"; 
    35         $sess->set( 'save', '$50' ); 
    36         echo "See what was saved: "; 
    37         var_dump( $sess->get( 'save' ) ); 
    38         echo "<br />\n"; 
     46        $queryString    =       $sess->getQueryString(); 
     47        echo '- <a href="' . $_SERVER['PHP_SELF'] . '?' . $queryString . '&amp;continue=try" title="'. $_SERVER['PHP_SELF'] . '?' . $queryString .'&amp;continue=try">Continue this session - or at least try to!</a> <br />'; 
    3948?> 
  • trunk/examples/index_sections.php

    r29 r31  
    4646                                'destroy' => array( 
    4747                                        'title' =>      'Destroy sessions', 
    48                                         'descr' =>      'Shows how to terminate a session.' 
     48                                        'descr' =>      'Shows how to terminate a session. Destroying a session also means to flush all session values.' 
     49                                ), 
     50                                'restart' => array( 
     51                                        'title' =>      'Restart', 
     52                                        'descr' =>      'Inactive session may restarted - of course, this will not restore the previous session values. ' 
     53                                                . 'Restarting a session means that you start over with an empty session container - but at least, the session will be active again!' 
    4954                                ), 
    5055                                'count' => array( 
  • trunk/patSession/Storage.php

    r29 r31  
    4242{ 
    4343   /** 
     44        * session variables 
     45        * @var  mixed $_sess temporary storage container 
     46        */ 
     47        var     $_sess  =       null; 
     48     
     49   /** 
     50        * session attributes 
     51        * @var  array $_sessAttributes  
     52        */ 
     53        var     $_sessAttributes        =       array(); 
     54         
     55   /** 
     56        * id string 
     57        * @var  mixed $_id  
     58        */ 
     59        var     $_id    =       null; 
     60         
     61   /** 
    4462        * internal state 
    4563        * @access protected 
     
    100118         
    101119   /** 
     120    * Start the session - interface for PHP4 
     121    *  
     122    * @final 
     123        * @access protected 
     124        * @param string $id name-prefix used for internal storage of session-data 
     125        * @param array $options additional session paramter and configuration values 
     126    * @see __construct() 
     127        */ 
     128    function patSession_Storage( $id = 'session', $options = array() ) 
     129        { 
     130                $this->__construct( $id, $options ); 
     131        } 
     132         
     133   /** 
     134        * Start the session 
     135        *  
     136        * - pass the configuration options 
     137    * - start session 
     138        * - perform security checks 
     139        * - increase session counter 
     140        *  
     141    * @final 
     142        * @access protected 
     143        * @param string $id name-prefix used for internal storage of session-data 
     144        * @param array $options additional session paramter and configuration values 
     145        */ 
     146        function        __construct( $id = 'session', $options = array() ) 
     147        { 
     148                $this->_id      =       $id; 
     149                $this->_setOptions( $options ); 
     150 
     151        $this->_start(); 
     152                 
     153                // init shutdown function on PHP 4 
     154                list( $version )        =   explode( '.', phpversion() ); 
     155                if( $version < 5 ) 
     156                { 
     157                        register_shutdown_function( array( $this, '_suspend' ) ); 
     158                } 
     159 
     160                $this->_state   =       'active'; 
     161                 
     162                // perform security checks 
     163                if( !$this->_checkSecurity() ) 
     164                { 
     165                        $this->sess     =       array(); 
     166                } 
     167                 
     168        $this->_initCounter(); 
     169    } 
     170         
     171   /** 
     172    * make sure to suspend session values on shutdown 
     173        * 
     174        * @access public 
     175        */ 
     176    function __destruct() 
     177    { 
     178            $this->_suspend(); 
     179    } 
     180     
     181   /** 
    102182        * get current state of sessoin 
    103183        * 
     
    128208                } 
    129209         
    130                 return implode( '&', $query ); 
     210                return implode( '&amp;', $query ); 
    131211    } 
    132212 
     
    134214        * recieve name of this session 
    135215        * 
    136         * @abstract 
     216        * @final 
    137217        * @access private 
    138218        * @return string $name session name 
     
    140220    function getName() 
    141221    { 
    142                 return null
     222                return $this->_sessAttributes['name']
    143223    } 
    144224 
     
    146226        * recieve id of this session 
    147227        * 
    148         * @abstract 
     228        * @final 
    149229        * @access private 
    150230        * @return string $id session id 
     
    152232    function getId() 
    153233    { 
    154                 return null; 
     234                if( $this->_state === 'destroyed' ) 
     235                { 
     236                        patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
     237                                                'Session is destroyed - no session id available', 
     238                                                'The session was destroyed before and the session id removed.' 
     239                                         ); 
     240                        return null; 
     241                } 
     242                 
     243                return $this->_sessAttributes['id']; 
    155244    } 
    156245         
     
    158247        * save data into session 
    159248        *  
    160         * @abstract 
     249        * @final 
    161250        * @access public 
    162251        * @param string $name name of variable 
     
    166255        function        set( $name, $value ) 
    167256        { 
     257                if( $this->_state !== 'active' ) 
     258                { 
     259                        return patErrorManager::raiseError( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
     260                                                'Cannot set value because session not active.', 
     261                                                'Either the session was destroyed, has expired or locked by security' 
     262                                         ); 
     263                } 
     264                 
     265                $this->_sess[$name]     =       $value; 
    168266                return true; 
    169267        } 
     
    172270        * get data from session 
    173271        *  
    174         * @abstract 
     272        * @final 
    175273        * @access public 
    176274        * @param string $name name of variable 
     
    179277        function        get( $name ) 
    180278        { 
     279                if( $this->_state !== 'active' ) 
     280                { 
     281                                return patErrorManager::raiseWarning( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
     282                                                'Cannot recieve value because session not active.', 
     283                                                'Either the session was destroyed, has expired or locked because of security reasons.' 
     284                                         ); 
     285                } 
     286                 
     287                if( isset( $this->_sess[$name] ) ) 
     288                { 
     289                        return $this->_sess[$name]; 
     290                } 
     291                 
    181292                return null; 
    182293        } 
     
    185296        * check wheter a session value exists 
    186297        *  
    187         * @abstract 
     298        * @final 
    188299        * @access public 
    189300        * @param string $name name of variable 
     
    192303        function        has( $name ) 
    193304        { 
    194                 return null; 
     305                if( $this->_state !== 'active' ) 
     306                { 
     307                                return patErrorManager::raiseWarning( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
     308                                                'Cannot recieve value because session not active.', 
     309                                                'Either the session was destroyed, has expired or locked because of security reasons.' 
     310                                         ); 
     311                } 
     312                 
     313                return isset( $this->_sess[$name] ); 
    195314        } 
    196315 
     
    198317        * unset data from session 
    199318        *  
    200         * @abstract 
     319        * @final 
    201320        * @access public 
    202321        * @param string $name name of variable 
     
    205324        function        clear( $name ) 
    206325        { 
    207                 return null; 
     326                if( $this->_state !== 'active' ) 
     327                { 
     328                        patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
     329                                                'Session is not active - nothing to clear', 
     330                                                'Either the session was destroyed, has expired or locked because of security reasons.' 
     331                                         ); 
     332                        return null; 
     333                } 
     334                 
     335                $value  =       null; 
     336                if( isset( $this->_sess[$name] ) ) 
     337                { 
     338                        $value  =       $this->_sess[$name]; 
     339                        unset( $this->_sess[$name] ); 
     340                } 
     341         
     342                return $value; 
    208343        } 
    209344 
     
    217352        function        destroy() 
    218353        { 
     354                if( $this->_state === 'destroyed' ) 
     355                { 
     356                        patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
     357                                                'Session is not active.', 
     358                                                'The session was destroyed before.' 
     359                                         ); 
     360                        return false; 
     361                } 
     362         
     363                // call event handler 
     364                if( is_callable( array( $this, '_handleDestroy' ) ) ) 
     365                { 
     366                        $this->_handleDestroy(); 
     367                } 
     368         
     369                $this->_sess    =       null; 
     370                $this->_state   =       'destroyed'; 
    219371                return true; 
    220372        } 
    221373         
    222374   /** 
     375    * restart a destroyed or locked sessionb 
     376        * 
     377        * @final 
     378        * @access public 
     379        * @return boolean $result true on success 
     380        * @see destroy 
     381        */ 
     382    function restart() 
     383    { 
     384            if( $this->_state ===  'active' ) 
     385                { 
     386                        return false; 
     387                } 
     388                 
     389                $this->_start(); 
     390                $this->_state   =       'active'; 
     391                 
     392                // perform security checks 
     393                if( !$this->_checkSecurity( true ) ) 
     394                { 
     395                        $this->sess     =       array(); 
     396                } 
     397                 
     398        $this->_initCounter(); 
     399        return true; 
     400    } 
     401         
     402         
     403   /** 
    223404        * create a new session and copy variables from the old one 
    224405        * 
     
    229410    function fork() 
    230411    { 
     412                if( $this->_state !== 'active' ) 
     413                { 
     414                        if( !$this->_checkSecurity( true ) ) 
     415                        { 
     416                                return patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
     417                                                'Session is not active.', 
     418                                                'Either the session was destroyed, has expired or locked because of security reasons: '. $this->_state.'.' 
     419                                         ); 
     420                        } 
     421                } 
     422                 
     423                // call event handler 
     424                if( is_callable( array( $this, '_handleFork' ) ) ) 
     425                { 
     426                        $this->_handleFork(); 
     427                } 
     428         
    231429                return true; 
    232430    } 
  • trunk/patSession/Storage/Cli.php

    r27 r31  
    77 * $Id$ 
    88 * 
    9  * @version     1.0.5 
     9 * @version     1.0.6 
    1010 * @package patSession 
    1111 * @subpackage Storage 
     
    3939{ 
    4040   /** 
    41         * session variables container 
    42         * @var  array $_sess  
    43         */ 
    44         var     $_sess  =       null; 
    45          
    46    /** 
    47         * id string 
    48         * @var  string $_id  
    49         */ 
    50         var     $_id    =       '42'; 
    51          
    52    /** 
    53         * session name 
    54         * @var  string $_id  
    55         */ 
    56         var     $_name  =       'patSession_Cli'; 
    57          
    58    /** 
    59         * constructor for PHP4 
    60         *  
    61         * @param string $id name-prefix used for internal storage of session-data 
    62         * @param array $options additional session paramter and configuration values 
    63         * @see __construct 
    64         */ 
    65         function        patSession_Storage_Cli( $id = 'session', $options = array() ) 
    66         { 
    67                 $this->__construct( $id, $options ); 
    68         } 
    69          
    70    /** 
    7141        * Start the session 
    72         *  
    7342        *  
    7443        * @param string $id name-prefix used for internal storage of session-data 
    7544        * @param array $options additional session paramter and configuration values 
    7645        */ 
    77         function        __construct( $id = 'session', $options = array()
     46        function        _start(
    7847        { 
    7948                // always start a new session 
    8049                $this->_sess    =       array(); 
    81                 $this->_state   =       'active'; 
    82                 $this->_initCounter(); 
     50                 
     51                if( !isset( $this->_sessAttributes['id'] ) ) 
     52                { 
     53                $this->_sessAttributes['id']    =   42; 
     54                } 
     55                 
     56                if( !isset( $this->_sessAttributes['name'] ) ) 
     57                { 
     58                $this->_sessAttributes['name']  =   'patSession_Cli'; 
     59                } 
    8360                 
    8461                // check whether the script runs as CLI processor 
     
    9067                                 ); 
    9168                } 
    92         } 
    93  
    94    /** 
    95         * recieve name of this session 
    96         * 
    97         * @access private 
    98         * @return string $name session name 
    99         */ 
    100     function getName() 
    101     { 
    102                 return $this->_name; 
    103     } 
    104  
    105    /** 
    106         * recieve id of this session 
    107         * 
    108         * @access private 
    109         * @return string $id session id 
    110         */ 
    111     function getId() 
    112     { 
    113                 if( $this->_state === 'destroyed' ) 
    114                 { 
    115                         patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    116                                                 'Session is destroyed - no session id available', 
    117                                                 'The session was destroyed before and the session id removed.' 
    118                                          ); 
    119                         return null; 
    120                 } 
    121          
    122                 return $this->_id; 
    123     } 
    124          
    125    /** 
    126         * save data into session 
    127         *  
    128         * @access public 
    129         * @param string $name name of variable 
    130         * @param mixed $value any value to be stored into session 
    131         * @return boolean $result true on success 
    132         */  
    133         function        set( $name, $value ) 
    134         { 
    135                 if( $this->_state !== 'active' ) 
    136                 { 
    137                                 return patErrorManager::raiseWarning( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    138                                                 'Cannot recieve value because session not active.', 
    139                                                 'Either the session was destroyed, has expired or locked because of security reasons.' 
    140                                          ); 
    141                 } 
    14269                 
    143                 $this->_sess[$name]     =       $value; 
    14470                return true; 
    14571        } 
    14672         
    14773   /** 
    148         * get data from session 
    149         *  
    150         * @access public 
    151         * @param string $name name of variable 
    152         * @return mixed $value the value from session or NULL if not set 
    153         */  
    154         function        get( $name ) 
    155         { 
    156                 if( $this->_state !== 'active' ) 
    157                 { 
    158                                 return patErrorManager::raiseWarning( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    159                                                 'Cannot recieve value because session not active.', 
    160                                                 'Either the session was destroyed, has expired or locked because of security reasons.' 
    161                                          ); 
    162                 } 
    163                  
    164                 if( isset( $this->_sess[$name] ) ) 
    165                 { 
    166                         return $this->_sess[$name]; 
    167                 } 
    168                  
    169                 return null; 
    170         } 
    171  
    172    /** 
    173         * check wheter a session value exists 
    174         *  
    175         * @access public 
    176         * @param string $name name of variable 
    177         * @return boolean $result true if the variable exists 
    178         */  
    179         function        has( $name ) 
    180         { 
    181                 if( $this->_state !== 'active' ) 
    182                 { 
    183                                 return patErrorManager::raiseWarning( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    184                                                 'Cannot recieve value because session not active.', 
    185                                                 'Either the session was destroyed, has expired or locked because of security reasons.' 
    186                                          ); 
    187                 } 
    188                  
    189                 return isset( $this->_sess[$name] ); 
    190         } 
     74    * suspend the session values 
     75    *  
     76    * Do nothing! In other words, don't make session values persistent 
     77        * 
     78        * @access private 
     79        * @return boolean $result true on success 
     80        */ 
     81    function _suspend() 
     82    { 
     83        return true; 
     84    } 
    19185         
    192    /** 
    193         * unset data from session 
    194         *  
    195         * @access public 
    196         * @param string $name name of variable 
    197         * @return mixed $value the value from session or NULL if not set 
    198         */  
    199         function        clear( $name ) 
    200         { 
    201                 if( $this->_state !== 'active' ) 
    202                 { 
    203                         patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    204                                                 'Session is not active - nothing to clear', 
    205                                                 'Either the session was destroyed, has expired or locked because of security reasons.' 
    206                                          ); 
    207                         return null; 
    208                 } 
    209                  
    210                 $value  =       null; 
    211                 if( isset( $this->_sess[$name] ) ) 
    212                 { 
    213                         $value  =       $this->_sess[$name]; 
    214                         unset( $this->_sess[$name] ); 
    215                 } 
    216          
    217                 return $value; 
    218         } 
    219  
    220    /** 
    221         * unset session variables and destroy session 
    222         *  
    223         * @access public 
    224         * @return boolean $result true on success 
    225         */  
    226         function        destroy() 
    227         { 
    228                 if( $this->_state === 'destroyed' ) 
    229                 { 
    230                         patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    231                                                 'Session is not active.', 
    232                                                 'The session was destroyed before.' 
    233                                          ); 
    234                         return false; 
    235                 } 
    236                  
    237                 $this->_sess    =       array(); 
    238                 $this->_state   =       'destroyed'; 
    239                 return true; 
    240         } 
    241          
    242    /** 
    243         * create a new session and copy variables from the old one 
    244         * 
    245         * @access public 
    246         * @return boolean $result true on success 
    247         * @todo think about storage of session values - what happens to $_SESSION 
    248         */ 
    249     function fork() 
    250     { 
    251                 if( $this->_state !== 'active' ) 
    252                 { 
    253                         if( !$this->_checkSecurity( true ) ) 
    254                         { 
    255                                 return patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    256                                                 'Session is not active.', 
    257                                                 'Either the session was destroyed, has expired or locked because of security reasons: '. $this->_state.'.' 
    258                                          ); 
    259                         } 
    260                 } 
    261          
    262                 return true; 
    263     } 
    264  
    26586   /** 
    26687        * set additional session options 
     
    27798                if( isset( $options['name'] ) ) 
    27899                { 
    279                         $this->_name  =       $options['name']; 
     100                        $this->_sessAttributes['name']        =       $options['name']; 
    280101                } 
    281102                 
     
    283104                if( isset( $options['id'] ) ) 
    284105                { 
    285                         $this->_id            =       $options['id']; 
     106                        $this->_sessAttributes['id']          =       $options['id']; 
    286107                } 
    287108                return true;             
  • trunk/patSession/Storage/Native.php

    r27 r31  
    88 * $Id$ 
    99 * 
    10  * @version     1.0.5 
     10 * @version     1.0.6 
    1111 * @package patSession 
    1212 * @subpackage Storage 
     
    2929{ 
    3030   /** 
    31         * session variables 
    32         * @var  array $_sess reference to the session-storage 
     31    * start session  
     32    *  
     33    * - start session (if not already running) 
     34    * - select storage container by id 
     35        * - store id in attributes 
     36        * - store name in attributes 
     37        * 
     38        * @access private 
     39        * @return boolean $result true on success 
    3340        */ 
    34         var     $_sess  =       null; 
    35          
    36    /** 
    37         * id string 
    38         * @var  string $_id  
    39         */ 
    40         var     $_id    =       null; 
    41          
    42    /** 
    43         * constructor for PHP4 
    44         *  
    45         * @param string $id name-prefix used for internal storage of session-data 
    46         * @param array $options additional session paramter and configuration values 
    47         * @see __construct 
    48         */ 
    49         function        patSession_Storage_Native( $id = 'session', $options = array() ) 
    50         { 
    51                 $this->__construct( $id, $options ); 
    52         } 
    53          
    54    /** 
    55         * Start the session 
    56         *  
    57         * - pass the configuration options 
    58         * - start php-session (if not running) 
    59         * - select the the sorage container by id 
    60         * - perform security checks 
    61         * - increase session counter 
    62         *  
    63         * @param string $id name-prefix used for internal storage of session-data 
    64         * @param array $options additional session paramter and configuration values 
    65         */ 
    66         function        __construct( $id = 'session', $options = array() ) 
    67         { 
    68                 $this->_id      =       $id; 
    69                 $this->_setOptions( $options ); 
    70                  
     41    function _start() 
     42    { 
    7143                //  start session if not startet 
    7244                if( !defined( 'SID' ) ) 
     
    8254                 
    8355                $this->_sess    =&      $_SESSION[$this->_id]; 
    84                 $this->_state   =       'active'; 
    85                  
    86                 // perform security checks 
    87                 if( !$this->_checkSecurity() ) 
    88                 { 
    89                         $this->sess     =       array(); 
    90                 } 
    9156         
    92         $this->_initCounter(); 
    93         } 
    94  
    95    /** 
    96         * recieve name of this session 
    97         * 
    98         * @access private 
    99         * @return string $name session name 
    100         */ 
    101     function getName() 
    102     { 
    103                 return session_name(); 
     57        $this->_sessAttributes['id']    =   session_id(); 
     58        $this->_sessAttributes['name']  =   session_name(); 
     59         
     60        return TRUE; 
    10461    } 
    10562 
    10663   /** 
    107         * recieve id of this session 
     64    * suspend the session values 
     65    *  
     66    * Make session values persistent 
    10867        * 
    10968        * @access private 
    110         * @return string $id session id 
     69        * @return boolean $result true on success 
    11170        */ 
    112     function getId() 
     71    function _suspend() 
    11372    { 
    114                 if( $this->_state === 'destroyed' ) 
    115                 { 
    116                         patErrorManager::raiseNotice( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    117                                                 'Session is destroyed - no session id available', 
    118                                                 'The session was destroyed before and the session id removed.' 
    119                                          ); 
    120                         return null; 
    121                 } 
    122                  
    123                 return session_id(); 
     73                // PHP does the trick automatically 
     74        return true; 
    12475    } 
    125          
     76 
    12677   /** 
    127         * save data into session 
     78        * event handler to destroy a the session 
    12879        *  
    129         * @access public 
    130         * @param string $name name of variable 
    131         * @param mixed $value any value to be stored into session 
     80        * @access private 
    13281        * @return boolean $result true on success 
    13382        */  
    134         function        set( $name, $value
     83        function        _handleDestroy(
    13584        { 
    136                 if( $this->_state !== 'active' ) 
    137                 { 
    138                         return patErrorManager::raiseError( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    139                                                 'Cannot set value because session not active.', 
    140                                                 'Either the session was destroyed, has expired or locked by security' 
    141                                          ); 
    142                 } 
    143                  
    144                 $this->_sess[$name]     =       $value; 
    145                 return true; 
    146         } 
    147          
    148    /** 
    149         * get data from session 
    150         *  
    151         * @access public 
    152         * @param string $name name of variable 
    153         * @return mixed $value the value from session or NULL if not set 
    154         */  
    155         function        get( $name ) 
    156         { 
    157                 if( $this->_state !== 'active' ) 
    158                 { 
    159                                 return patErrorManager::raiseWarning( 'patSession:' . PATSESSION_ERROR_NOT_ACTIVE, 
    160                                                 'Cannot recieve value because session not active.', 
    161                                                 'Either the session was destroyed, has expired or locked because of security reasons.' 
    162                                          ); 
    163                 } 
    164                  
    165                 if( isset( $this->_sess[$name] ) ) 
    166                 { 
    167                         return $this->_sess[$name]; 
    168                 } 
    169                  
    170                 return null; 
    171         } 
    172  
    173    /** 
    174         * check wheter a session value exists 
    175         *  
    176         * @access public 
    177 </