Class Session (namespace Nette\Web)


Provides access to session namespaces as well as session settings and management methods.

Object
   |
   --Session
Copyright: Copyright (c) 2004, 2010 David Grudl
Located: in /Web/Session.php (line 21)
Public Method Summary
Session
void
clean ()
Cleans and minimizes meta structures.
void
close ()
Ends the current session and store session data.
void
destroy ()
Destroys all data registered to a session.
bool
exists ()
Does session exists for the current request?
string
Generates key as protection against Session Hijacking & Fixation.
array
Returns the session cookie parameters.
string
getId ()
Returns the current session ID. Don't make dependencies, can be changed for each request.
ArrayIterator
Iteration over all namespaces.
string
getName ()
Gets the session name.
SessionNamespace
getNamespace (string $namespace, [string $class = 'SessionNamespace'])
Returns specified session namespace.
array
Returns all session options.
bool
hasNamespace (string $namespace)
Checks if a session namespace exist and is not empty.
bool
Has been session started?
void
Regenerates the session ID.
Session
setCookieParams (string $path, [string $domain = NULL], [bool $secure = NULL])
Sets the session cookie parameters.
Session
setExpiration (string|int|DateTime $time)
Sets the amount of time allowed between requests before the session will be terminated.
Session
setName (string $name)
Sets the session name to a specified one.
Session
setOptions ($options)
Sets session options.
Session
setSavePath ($path)
Sets path of the directory used to save session data.
void
start ()
Starts and initializes session data.
Protected Method Summary
protected IHttpRequest
protected IHttpResponse
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Constant Summary
int DEFAULT_FILE_LIFETIME 10800

line 24

Default file lifetime is 3 hours
Variable Summary
callback $verificationKeyGenerator

line 27

Validation key generator

Method Details

line 60

__construct

public Session __construct ()

Output
Session  

line 377

clean

public void clean ()

Cleans and minimizes meta structures.

Output
void  

line 188

close

public void close ()

Ends the current session and store session data.

Output
void  

line 203

destroy

public void destroy ()

Destroys all data registered to a session.

Output
void  

line 224

exists

public bool exists ()

Does session exists for the current request?

Output
bool  

line 296

generateVerificationKey

public string generateVerificationKey ()

Generates key as protection against Session Hijacking & Fixation.

Output
string  

line 539

getCookieParams

public array getCookieParams ()

Returns the session cookie parameters.

Output
array containing items: lifetime, path, domain, secure, httponly

line 579

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 589

getHttpResponse

protected IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 255

getId

public string getId ()

Returns the current session ID. Don't make dependencies, can be changed for each request.

Output
string  

line 357

getIterator

public ArrayIterator getIterator ()

Iteration over all namespaces.

Output
ArrayIterator  

line 285

getName

public string getName ()

Gets the session name.

Output
string  

line 322

getNamespace

public SessionNamespace getNamespace (string $namespace, [string $class = 'SessionNamespace'])

Returns specified session namespace.

Input
string $namespace
string $class
Output
SessionNamespace  
Throws
throws InvalidArgumentException

line 433

getOptions

public array getOptions ()

Returns all session options.

Output
array  

line 342

hasNamespace

public bool hasNamespace (string $namespace)

Checks if a session namespace exist and is not empty.

Input
string $namespace
Output
bool  

line 177

isStarted

public bool isStarted ()

Has been session started?

Output
bool  

line 236

regenerateId

public void regenerateId ()

Regenerates the session ID.

Output
void  
Throws
throws InvalidStateException

line 524

setCookieParams

public Session setCookieParams (string $path, [string $domain = NULL], [bool $secure = NULL])

Sets the session cookie parameters.

Input
string $path path
string $domain domain
bool $secure secure
Output
Session provides a fluent interface

line 498

setExpiration

public Session setExpiration (string|int|DateTime $time)

Sets the amount of time allowed between requests before the session will be terminated.

Input
string|int|DateTime $time time, value 0 means "until the browser is closed"
Output
Session provides a fluent interface

line 267

setName

public Session setName (string $name)

Sets the session name to a specified one.

Input
string $name
Output
Session provides a fluent interface

line 418

setOptions

public Session setOptions ($options)

Sets session options.

Input
$options
Output
Session provides a fluent interface
Throws
throws InvalidStateException
throws NotSupportedException

line 550

setSavePath

public Session setSavePath ($path)

Sets path of the directory used to save session data.

Input
$path
Output
Session provides a fluent interface

line 72

start

public void start ()

Starts and initializes session data.

Output
void  
Throws
throws InvalidStateException