ZenMagick 0.9.10


org.zenmagick.mvc.session\ZMSession
mvc\session\ZMSession.php at line 31

Class ZMSession

ZMObject
└─ZMSession

public class ZMSession
extends ZMObject

A basic, cookies only, session class.

Author:
DerManoMann
Todo:
allow to expire session after a given time (will need cookie update for each request)

Constant Summary
final static str

DEFAULT_NAME

The default session name.

final static str

DEFAULT_NAMESPACE_PREFIX

The default namespace prefix for session keys.

final static str

SESSION_TOKEN_KEY

A magic session key used to validate forms.

Fields inherited from org.zenmagick.core\ZMObject
properties_
Method Summary
void

__construct(mixed domain, string name, boolean secure, boolean autostart)

Create new instance.

void

close()

Close session rather than wait for the end of request handling.

void

destroy()

Destroy the current session.

void

getData()

Get the current session data.

string

getId()

Get the session id.

string

getName()

Get the session name.

string

getToken(boolean renew)

Get the session token.

mixed

getValue(string name, string namespace)

Get a session value.

boolean

isNew()

Check if starting this session would create a new session or if a session exists.

boolean

isStarted()

Check if we have a session yet.

void

regenerate()

Regenerate session.

void

registerSessionHandler(mixed handler, mixed A)

Register a session handler.

mixed

setValue(string name, mxied value, string namespace)

Set a session value.

boolean

start()

Start session.

Methods inherited from org.zenmagick.core\ZMObject
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Constant Detail

mvc\session\ZMSession.php at line 33

DEFAULT_NAME

public final static str DEFAULT_NAME = 'zmid'

The default session name.


mvc\session\ZMSession.php at line 37

DEFAULT_NAMESPACE_PREFIX

public final static str DEFAULT_NAMESPACE_PREFIX = '__ZM_NSP__'

The default namespace prefix for session keys.


mvc\session\ZMSession.php at line 35

SESSION_TOKEN_KEY

public final static str SESSION_TOKEN_KEY = '__ZM_TOKEN__'

A magic session key used to validate forms.


Method Detail

mvc\session\ZMSession.php at line 55

__construct

public void __construct(mixed domain, string name, boolean secure, boolean autostart)

Create new instance.

If an existing session is detected (via isNew()), the session is automatically started.

Parameters:
name - Optional session name; default is ZMSession::DEFAULT_NAME.
secure - Indicate whether the session cookie should be secure or not; default is true.
autostart - Indicate whether the session should be started immediately or on demand.

mvc\session\ZMSession.php at line 205

close

public void close()

Close session rather than wait for the end of request handling.


mvc\session\ZMSession.php at line 159

destroy

public void destroy()

Destroy the current session.


mvc\session\ZMSession.php at line 134

getData

public void getData()

Get the current session data.


mvc\session\ZMSession.php at line 227

getId

public string getId()

Get the session id.

Returns:
The session id or null.

mvc\session\ZMSession.php at line 236

getName

public string getName()

Get the session name.

Returns:
The session name.

mvc\session\ZMSession.php at line 331

getToken

public string getToken(boolean renew)

Get the session token.

A new token will be created if none exists.

Parameters:
renew - If true a new token will be generated; default is false.
Returns:
The token.

mvc\session\ZMSession.php at line 291

getValue

public mixed getValue(string name, string namespace)

Get a session value.

Parameters:
name - The name.
namespace - Optional namespace; default is null for none.
Returns:
The value or null.

mvc\session\ZMSession.php at line 127

isNew

public boolean isNew()

Check if starting this session would create a new session or if a session exists.

This will just check for a cookie with the configured session name.

Returns:
true if starting this session would result in a new session.

mvc\session\ZMSession.php at line 115

isStarted

public boolean isStarted()

Check if we have a session yet.

Returns:
true if the session has been already started.

mvc\session\ZMSession.php at line 178

regenerate

public void regenerate()

Regenerate session.

This will create a new session id while keeping existing session data.


mvc\session\ZMSession.php at line 313

registerSessionHandler

public void registerSessionHandler(mixed handler, mixed A)

Register a session handler.

Parameters:
A - session handler instance.

mvc\session\ZMSession.php at line 248

setValue

public mixed setValue(string name, mxied value, string namespace)

Set a session value.

Parameters:
name - The name; default is null to clear all data.
value - The value; use null to remove; default is null.
namespace - Optional namespace; default is null for none.
Returns:
The old value or null.

mvc\session\ZMSession.php at line 143

start

public boolean start()

Start session.

Returns:
true if a session was started, false if not.

ZenMagick 0.9.10