Session.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Session
- Since
- Preview Release 0.2
- Version
- $Id: Session.php 25121 2012-11-13 21:51:23Z matthew $
\Zend_Session
Zend_Session
- Parent(s)
- \Zend_Session_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
_THROW_NOT_WRITABLE_MSG
= 'Zend_Session is currently marked as read-only.'Error message thrown when an action requires modification, but current Zend_Session has been marked as read-only.
Inherited from: \Zend_Session_Abstract::_THROW_NOT_WRITABLE_MSG- Inherited_from
- \Zend_Session_Abstract::_THROW_NOT_WRITABLE_MSG
_THROW_NOT_READABLE_MSG
= 'Zend_Session is not marked as readable.'Error message thrown when an action requires reading session data, but current Zend_Session is not marked as readable.
Inherited from: \Zend_Session_Abstract::_THROW_NOT_READABLE_MSG- Inherited_from
- \Zend_Session_Abstract::_THROW_NOT_READABLE_MSG
Properties

array $_defaultOptions = array('save_path' => null, 'name' => null, 'save_handler' => null, 'gc_probability' => null, 'gc_divisor' => null, 'gc_maxlifetime' => null, 'serialize_handler' => null, 'cookie_lifetime' => null, 'cookie_path' => null, 'cookie_domain' => null, 'cookie_secure' => null, 'cookie_httponly' => null, 'use_cookies' => null, 'use_only_cookies' => 'on', 'referer_check' => null, 'entropy_file' => null, 'entropy_length' => null, 'cache_limiter' => null, 'cache_expire' => null, 'use_trans_sid' => null, 'bug_compat_42' => null, 'bug_compat_warn' => null, 'hash_function' => null, 'hash_bits_per_character' => null)Private list of php's ini values for ext/session null values will default to the php.ini value, otherwise the value below will overwrite the default ini value, unless the user has set an option explicity with setOptions()
array('save_path' => null, 'name' => null, 'save_handler' => null, 'gc_probability' => null, 'gc_divisor' => null, 'gc_maxlifetime' => null, 'serialize_handler' => null, 'cookie_lifetime' => null, 'cookie_path' => null, 'cookie_domain' => null, 'cookie_secure' => null, 'cookie_httponly' => null, 'use_cookies' => null, 'use_only_cookies' => 'on', 'referer_check' => null, 'entropy_file' => null, 'entropy_length' => null, 'cache_limiter' => null, 'cache_expire' => null, 'use_trans_sid' => null, 'bug_compat_42' => null, 'bug_compat_warn' => null, 'hash_function' => null, 'hash_bits_per_character' => null)Details- Type
- array

bool $_defaultOptionsSet = falseWhether the default options listed in Zend_Session::$_localOptions have been set
falseDetails- Type
- bool

bool $_destroyed = falseWhether or not session has been destroyed via session_destroy()
falseDetails- Type
- bool

array $_expiringData = array()Since expiring data is handled at startup to avoid __destruct difficulties, the data that will be expiring at end of this request is held here
Inherited from: \Zend_Session_Abstract::$$_expiringDataarray()Details- Type
- array
- Inherited_from
- \Zend_Session_Abstract::$$_expiringData

array $_localOptions = array('strict' => '_strict', 'remember_me_seconds' => '_rememberMeSeconds', 'throw_startup_exceptions' => '_throwStartupExceptions')List of options pertaining to Zend_Session that can be set by developers using Zend_Session::setOptions().
This list intentionally duplicates the individual declaration of static "class" variables by the same names.
array('strict' => '_strict', 'remember_me_seconds' => '_rememberMeSeconds', 'throw_startup_exceptions' => '_throwStartupExceptions')Details- Type
- array

bool $_readable = falseWhether or not session permits reading (reading data in $_SESSION[])
Inherited from: \Zend_Session_Abstract::$$_readablefalseDetails- Type
- bool
- Inherited_from
- \Zend_Session_Abstract::$$_readable

int $_regenerateIdState = 0Whether or not the session id has been regenerated this request.
Id regeneration state <0 - regenerate requested when session is started 0 - do nothing
0 - already called session_regenerate_id()
0Details- Type
- int

int $_rememberMeSeconds = 1209600Default number of seconds the session will be remembered for when asked to be remembered
1209600Details- Type
- int

\Zend_Session_SaveHandler_Interface $_saveHandler = nullA reference to the set session save handler
nullDetails

bool $_sessionCookieDeleted = falseWhether or not session id cookie has been deleted
falseDetails- Type
- bool

bool $_sessionStarted = falseCheck whether or not the session was started
falseDetails- Type
- bool

bool $_strict = falseWhether or not session must be initiated before usage
falseDetails- Type
- bool

bool|\bitset $_throwStartupExceptions = true$_throwStartupException
<p>This could also be a combiniation of error codes to catch</p>trueDetails- Type
- bool | \bitset

bool $_writable = falseWhether or not session permits writing (modification of $_SESSION[])
Inherited from: \Zend_Session_Abstract::$$_writablefalseDetails- Type
- bool
- Inherited_from
- \Zend_Session_Abstract::$$_writable
Methods

_checkId(string $id) : boolPerform a hash-bits check on the session ID
| Name | Type | Description |
|---|---|---|
| $id | string | Session ID |
| Type | Description |
|---|---|
| bool |

_namespaceGet(string $namespace, string $name = null) : mixednamespaceGet() - Get $name variable from $namespace, returning by reference.
Inherited from: \Zend_Session_Abstract::_namespaceGet()| Name | Type | Description |
|---|---|---|
| $namespace | string | |
| $name | string |
| Type | Description |
|---|---|
| mixed |

_namespaceGetAll(string $namespace) : mixednamespaceGetAll() - Get an array containing $namespace, including expiring data.
Inherited from: \Zend_Session_Abstract::_namespaceGetAll()| Name | Type | Description |
|---|---|---|
| $namespace | string |
| Type | Description |
|---|---|
| mixed |

_namespaceIsset(string $namespace, string $name = null) : boolnamespaceIsset() - check to see if a namespace or a variable within a namespace is set
Inherited from: \Zend_Session_Abstract::_namespaceIsset()| Name | Type | Description |
|---|---|---|
| $namespace | string | |
| $name | string |
| Type | Description |
|---|---|
| bool |

_namespaceUnset(string $namespace, string $name = null) : voidnamespaceUnset() - unset a namespace or a variable within a namespace
Inherited from: \Zend_Session_Abstract::_namespaceUnset()| Name | Type | Description |
|---|---|---|
| $namespace | string | |
| $name | string |
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

_processStartupMetadataGlobal() : void_processGlobalMetadata() - this method initizes the sessions GLOBAL metadata, mostly global data expiration calculations.

_processValidators() : void_processValidator() - internal function that is called in the existence of VALID metadata
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

destroy(bool $remove_cookie = true, bool $readonly = true) : voiddestroy() - This is used to destroy session data, and optionally, the session cookie itself
| Name | Type | Description |
|---|---|---|
| $remove_cookie | bool |
|
| $readonly | bool |
|

expireSessionCookie() : voidexpireSessionCookie() - Sends an expired session id cookie, causing the client to delete the session cookie

forgetMe() : voidforgetMe() - Write a volatile session cookie, removing any persistent cookie that may have existed.
The session would end upon, for example, termination of a web browser program.

getIterator() : \ArrayObjectgetIterator() - return an iteratable object for use in foreach and the like, this completes the IteratorAggregate interface
| Type | Description |
|---|---|
| \ArrayObject |
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

getOptions(string $optionName = null) : array | stringgetOptions()
| Name | Type | Description |
|---|---|---|
| $optionName | string | OPTIONAL |
| Type | Description |
|---|---|
| array | string |

getSaveHandler() : \Zend_Session_SaveHandler_InterfacegetSaveHandler() - Get the session Save Handler
| Type | Description |
|---|---|
| \Zend_Session_SaveHandler_Interface |

isDestroyed() : boolWhether or not session has been destroyed via session_destroy()
| Type | Description |
|---|---|
| bool |

isReadable() : boolisReadable() - returns a boolean indicating if namespaces can write (use setters)
| Type | Description |
|---|---|
| bool |

isRegenerated() : boolisRegenerated() - convenience method to determine if session_regenerate_id() has been called during this request by Zend_Session.
| Type | Description |
|---|---|
| bool |

isStarted() : boolisStarted() - convenience method to determine if the session is already started.
| Type | Description |
|---|---|
| bool |

isWritable() : boolisWritable() - returns a boolean indicating if namespaces can write (use setters)
| Type | Description |
|---|---|
| bool |

namespaceGet(string $namespace) : arraynamespaceGet() - get all variables in a namespace Deprecated: Use getIterator() in Zend_Session_Namespace.
| Name | Type | Description |
|---|---|---|
| $namespace | string |
| Type | Description |
|---|---|
| array |

namespaceIsset(string $namespace) : boolnamespaceIsset() - check to see if a namespace is set
| Name | Type | Description |
|---|---|---|
| $namespace | string |
| Type | Description |
|---|---|
| bool |

namespaceUnset(string $namespace) : voidnamespaceUnset() - unset a namespace or a variable within a namespace
| Name | Type | Description |
|---|---|---|
| $namespace | string |
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

regenerateId() : voidregenerateId() - Regenerate the session id.
Best practice is to call this after session is started. If called prior to session starting, session id will be regenerated at start time.
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

registerValidator(\Zend_Session_Validator_Interface $validator) : voidregisterValidator() - register a validator that will attempt to validate this session for every future request
| Name | Type | Description |
|---|---|---|
| $validator | \Zend_Session_Validator_Interface |

rememberMe(int $seconds = null) : voidrememberMe() - Write a persistent cookie that expires after a number of seconds in the future.
If no number of seconds is specified, then this defaults to self::$_rememberMeSeconds. Due to clock errors on end users' systems, large values are recommended to avoid undesirable expiration of session cookies.
| Name | Type | Description |
|---|---|---|
| $seconds | int | OPTIONAL specifies TTL for cookie in seconds from present time |

rememberUntil(int $seconds = 0) : voidrememberUntil() - This method does the work of changing the state of the session cookie and making sure that it gets resent to the browser via regenerateId()
| Name | Type | Description |
|---|---|---|
| $seconds | int |

sessionExists() : boolsessionExists() - whether or not a session exists for the current request
| Type | Description |
|---|---|
| bool |

setId(string $id) : voidsetId() - set an id to a user specified id
| Name | Type | Description |
|---|---|---|
| $id | string |
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

setOptions(array $userOptions = array()) : voidsetOptions - set both the class specified
| Name | Type | Description |
|---|---|---|
| $userOptions | array |
|
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

setSaveHandler( $saveHandler) : voidsetSaveHandler() - Session Save Handler assignment
| Name | Type | Description |
|---|---|---|
| $saveHandler |

start(bool | array $options = false) : voidstart() - Start the session.
| Name | Type | Description |
|---|---|---|
| $options | bool | array | OPTIONAL Either user supplied options, or flag indicating if start initiated automatically |
| Exception | Description |
|---|---|
| \Zend_Session_Exception |

writeClose(bool $readonly = true) : voidwriteClose() - Shutdown the sesssion, close writing and detach $_SESSION from the back-end storage mechanism.
This will complete the internal data transformation on this request.
| Name | Type | Description |
|---|---|---|
| $readonly | bool |
|