PHP Class Bluz\Session\Session

Author: Anton Shevchuk
Inheritance: use trait Bluz\Common\Options
Show file Open project: bluzphp/framework Class Usage Examples

Protected Properties

Property Type Description
$adapter Session save handler
$name value returned by session_name()
$namespace namespace

Public Methods

Method Description
contains ( string $key ) : boolean Isset
cookieExists ( ) : boolean Returns true if session ID is set
delete ( string $key ) : void Unset
destroy ( ) : void Destroy/end a session
expireSessionCookie ( ) : void Expire the session cookie
get ( string $key ) : mixed Get value by key
getAdapter ( ) : SessionHandlerInterface Get SaveHandler Object
getId ( ) : string Get session ID
getName ( ) : string Get session name
getNamespace ( ) : string Get Namespace
regenerateId ( boolean $deleteOldSession = true ) : boolean Regenerate id
sessionExists ( ) : boolean Does a session started and is it currently active?
set ( string $key, mixed $value ) : void Set key/value pair
setAdapter ( SessionHandlerInterface $saveHandler ) : Session Set session save handler object
setId ( string $id ) : Session Set session ID
setName ( string $name ) : Session Attempt to set the session name
setNamespace ( string $namespace ) : Session Set Namespace
setSessionCookieLifetime ( integer $ttl ) : void Set the session cookie lifetime
start ( ) : void Start session

Protected Methods

Method Description
initAdapter ( ) : boolean Register Save Handler with ext/session
setSavePath ( string $savePath ) : Session Set session save path

Method Details

contains() public method

Isset
public contains ( string $key ) : boolean
$key string
return boolean

cookieExists() public method

Returns true if session ID is set
public cookieExists ( ) : boolean
return boolean

delete() public method

Unset
public delete ( string $key ) : void
$key string
return void

destroy() public method

Destroy/end a session
public destroy ( ) : void
return void

expireSessionCookie() public method

Sends a session cookie with no value, and with an expiry in the past.
public expireSessionCookie ( ) : void
return void

get() public method

Get value by key
public get ( string $key ) : mixed
$key string
return mixed

getAdapter() public method

Get SaveHandler Object
public getAdapter ( ) : SessionHandlerInterface
return SessionHandlerInterface

getId() public method

Proxies to {@link session_id()}
public getId ( ) : string
return string

getName() public method

Proxies to {@link session_name()}.
public getName ( ) : string
return string

getNamespace() public method

Get Namespace
public getNamespace ( ) : string
return string

initAdapter() protected method

Since ext/session is coupled to this particular session manager register the save handler with ext/session.
protected initAdapter ( ) : boolean
return boolean

regenerateId() public method

Regenerate the session ID, using session save handler's native ID generation Can safely be called in the middle of a session.
public regenerateId ( boolean $deleteOldSession = true ) : boolean
$deleteOldSession boolean
return boolean

sessionExists() public method

Does a session started and is it currently active?
public sessionExists ( ) : boolean
return boolean

set() public method

Set key/value pair
public set ( string $key, mixed $value ) : void
$key string
$value mixed
return void

setAdapter() public method

Set session save handler object
public setAdapter ( SessionHandlerInterface $saveHandler ) : Session
$saveHandler SessionHandlerInterface
return Session

setId() public method

Can safely be called in the middle of a session.
public setId ( string $id ) : Session
$id string
return Session

setName() public method

If the session has already been started, or if the name provided fails validation, an exception will be raised.
public setName ( string $name ) : Session
$name string
return Session

setNamespace() public method

Set Namespace
public setNamespace ( string $namespace ) : Session
$namespace string
return Session

setSavePath() protected method

Set session save path
protected setSavePath ( string $savePath ) : Session
$savePath string
return Session

setSessionCookieLifetime() public method

If a session already exists, destroys it (without sending an expiration cookie), regenerates the session ID, and restarts the session.
public setSessionCookieLifetime ( integer $ttl ) : void
$ttl integer TTL in seconds
return void

start() public method

if No session currently exists, attempt to start it. Calls {@link isValid()} once session_start() is called, and raises an exception if validation fails.
public start ( ) : void
return void

Property Details

$adapter protected property

Session save handler
protected $adapter

$name protected property

value returned by session_name()
protected $name

$namespace protected property

namespace
protected $namespace