ZenMagick 0.9.8


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

Class ZMSession

ZMObject
└─ZMSession

public class ZMSession
extends ZMObject

A basic, cookies only, session class.

Author:
DerManoMann
Version:
$Id: ZMObject.php 2556 2009-10-31 07:38:13Z dermanomann $

Field Summary
final str

DEFAULT_NAME

The default session name.

final str

DEFAULT_NAMESPACE_PREFIX

The default namespace prefix for session keys.

final str

SESSION_TAG_KEY

A magic session key used to identify new sessions.

final str

SESSION_TOKEN_KEY

A magic session key used to validate forms.

Fields inherited from org.zenmagick.core.ZMObject
properties_
Constructor Summary

ZMSession(string name, boolean secure)

Create new instance.

Method Summary
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 this is a new session or resumed.

boolean

isStarted()

Check if we have a session yet.

static boolean

isValidSID(string sid)

Check if the given sid is valid.

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
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

\mvc\session\ZMSession.php at line 32

DEFAULT_NAME

public final str DEFAULT_NAME = 'zmid'

The default session name.


\mvc\session\ZMSession.php at line 38

DEFAULT_NAMESPACE_PREFIX

public final str DEFAULT_NAMESPACE_PREFIX = '__ZM_NSP__'

The default namespace prefix for session keys.


\mvc\session\ZMSession.php at line 34

SESSION_TAG_KEY

public final str SESSION_TAG_KEY = '__ZM_TAG__'

A magic session key used to identify new sessions.


\mvc\session\ZMSession.php at line 36

SESSION_TOKEN_KEY

public final str SESSION_TOKEN_KEY = '__ZM_TOKEN__'

A magic session key used to validate forms.


Constructor Detail

\mvc\session\ZMSession.php at line 53

ZMSession

public ZMSession(string name, boolean secure)

Create new instance.

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

Method Detail

\mvc\session\ZMSession.php at line 198

close

public void close()

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


\mvc\session\ZMSession.php at line 156

destroy

public void destroy()

Destroy the current session.


\mvc\session\ZMSession.php at line 129

getData

public void getData()

Get the current session data.


\mvc\session\ZMSession.php at line 216

getId

public string getId()

Get the session id.

Returns:
The session id or null.

\mvc\session\ZMSession.php at line 225

getName

public string getName()

Get the session name.

Returns:
The session name or null.

\mvc\session\ZMSession.php at line 334

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 281

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 121

isNew

public boolean isNew()

Check if this is a new session or resumed.

This will return true in the following cases:

Returns:
true if this is a new session.

\mvc\session\ZMSession.php at line 105

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 317

isValidSID

public static boolean isValidSID(string sid)

Check if the given sid is valid.

Parameters:
sid - The sid.
Returns:
true if the sid is valid.

\mvc\session\ZMSession.php at line 170

regenerate

public void regenerate()

Regenerate session.

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


\mvc\session\ZMSession.php at line 302

registerSessionHandler

public void registerSessionHandler(mixed handler, mixed A)

Register a session handler.

Parameters:
A - session handler instance.

\mvc\session\ZMSession.php at line 237

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 138

start

public boolean start()

Start session.

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

ZenMagick 0.9.8