Changeset 54 for branches

Show
Ignore:
Timestamp:
05/10/07 11:56:46 (2 years ago)
Author:
gerd
Message:

Added options to set cookie parameter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/patSession2/patSession/Storage.php

    r52 r54  
    55 * $Id$ 
    66 * 
    7  * @version     2.1.1 
     7 * @version     2.2.0 
    88 * @package patSession 
    99 * @subpackage Storage 
     
    103103         
    104104   /** 
     105    * cookie parameter 
     106    * @access protected 
     107    * @var  string $_cookieParam 
     108    */ 
     109    protected   $_cookieParam =   array( 
     110                        'lifetime'  =>  0, 
     111                        'path'      =>  '/', 
     112                        'domain'    =>  null, 
     113                        'secure'    =>  false 
     114                    ); 
     115     
     116   /** 
    105117        * security policy 
    106118        * Default values: 
     
    332344        */  
    333345        public function set( $name, $value ) 
    334         { 
    335                if( $this->_state !== 'active' ) { 
     346        {           
     347            if( $this->_state !== 'active' ) { 
    336348                        $error =& patErrorManager::raiseError( 'patSession:' . patSession::ERROR_NOT_ACTIVE, 
    337349                                                'Cannot set value because session not active.', 
     
    342354                 
    343355                $this->_sess[$name]     =       $value; 
     356                 
    344357                return true; 
    345358        } 
     
    750763                        // try to set a cookie                   
    751764                        if( $this->_tokenMode == 'any' || $this->_tokenMode == 'cookie' ) { 
    752                                 setcookie( $this->_tokenName, $token ); 
     765                                setcookie(  $this->_tokenName 
     766                            , $token 
     767                            , $this->_cookieParam['lifetime'] 
     768                            , $this->_cookieParam['path'] 
     769                            , $this->_cookieParam['domain'] 
     770                            , $this->_cookieParam['secure']  
     771                        ); 
    753772                        } 
    754773                } 
     
    790809    protected function _setOptions( &$options ) 
    791810    { 
     811        // cookie parametzer 
     812        if( isset( $options['cookie-lifetime'] ) ) { 
     813            $this->_cookieParam['lifetime'] =   $options['cookie-lifetime']; 
     814        } 
     815        if( isset( $options['cookie-path'] ) ) { 
     816            $this->_cookieParam['path']     =   $options['cookie-path']; 
     817        } 
     818        if( isset( $options['cookie-domain'] ) ) { 
     819            $this->_cookieParam['domain']   =   $options['cookie-domain']; 
     820        } 
     821        if( isset( $options['cookie-secure'] ) ) { 
     822            $this->_cookieParam['secure']   =   $options['cookie-secure']; 
     823        } 
     824 
    792825        // set id-prefix 
    793826        if( isset( $options['id-prefix'] ) ) { 
  • branches/patSession2/patSession/Storage/Cli.php

    r42 r54  
    5858                 
    5959                // check whether the script runs as CLI processor 
    60                 if( !isset( $_SERVER['argv'] ) || empty(  $_SERVER['argv'] ) ) { 
     60                if( !isset( $_SERVER['argc'] ) ) { 
    6161                        patErrorManager::raiseWarning( 'patSession:Cli:1', 
    6262                                        'Storage driver "Cli" loaded!', 
  • branches/patSession2/patSession/Storage/Native.php

    r52 r54  
    88 * $Id$ 
    99 * 
    10  * @version     2.0.2 
     10 * @version     2.1.0 
    1111 * @package patSession 
    1212 * @subpackage Storage 
     
    163163                        $this->_sessId = $options['id']; 
    164164                } 
    165                  
    166                 return parent::_setOptions( $options ); 
     165 
     166        $result =   parent::setOptions( $options ); 
     167 
     168        session_set_cookie_params(  $this->_cookieParam['lifetime'] 
     169                                    , $this->_cookieParam['path'] 
     170                                    , $this->_cookieParam['domain'] 
     171                                    , $this->_cookieParam['secure']  
     172                                ); 
     173 
     174                return $result; 
    167175    } 
    168176}