ZenMagick 0.9.1


org.zenmagick.ZMSession

Class ZMSession

ZMObject
|
+--ZMSession

public class ZMSession
extends ZMObject

Simple wrapper around $_SESSION to centralise access.

Author:
mano
Version:
$Id: ZMSession.php 948 2008-03-29 07:35:41Z DerManoMann $

Constructor Summary

ZMSession()

Create new instance.

Method Summary
void

clear()

Clear the session.

void

clearMessages()

Clear all session messages.

int

getAccountId()

Get the account id.

string

getClientAddress()

Get the client ip address.

string

getClientHostname()

Get the client host name.

string

getCurrencyCode()

Get currency code.

ZMLanguage

getLanguage()

Get the language.

int

getLanguageId()

Get the language id.

string

getLoginFollowUp()

Check if a follow up url exists that should be loaded after a login.

void

getMessages(array Messages.)

Get all session messages.

char

getType()

Returns the current session type.

mixed

getValue(string name)

Get a session value.

mixed

getZCShoppingCart()

Get the current shopping cart.

boolean

isAnonymous()

Returns true if the user is not logged in at all.

boolean

isGuest()

Returns true if the user is a guest user.

boolean

isOpen()

Check if a proper session has been started yet.

boolean

isRegistered()

Returns true if the user is a registered user.

boolean

isValid()

Check if the current session is valid and open.

void

markRequestAsLoginFollowUp()

Mark current request for return after login.

void

recreate(boolean force)

Recreate session.

void

restoreCart()

Restore the shopping cart contents.

void

setAccount(ZMAccount account)

Set the account for the current session.

void

setCurrencyCode(string currencyCode)

Set currency code.

void

setLanguage(ZMLanguage language)

Set the language.

void

setMessages(array messages)

Save the given messages in the session.

void

setValue(string name, mixed value)

Create a session value.

Methods inherited from org.zenmagick.ZMObject
backtrace, create, log, singleton

Constructor Detail

ZMSession

public ZMSession()

Create new instance. /


Method Detail

clear

public void clear()

Clear the session.

This will effectively logoff the curent account. /


clearMessages

public void clearMessages()

Clear all session messages. /


getAccountId

public int getAccountId()

Get the account id.

Returns:
The account id for the currently logged in user or 0.

getClientAddress

public string getClientAddress()

Get the client ip address.

Returns:
The client IP address or null.

getClientHostname

public string getClientHostname()

Get the client host name.

Returns:
The client host name or null.

getCurrencyCode

public string getCurrencyCode()

Get currency code.

Returns:
The session currency code or null.

getLanguage

public ZMLanguage getLanguage()

Get the language.

Returns:
The language or null.

getLanguageId

public int getLanguageId()

Get the language id.

Returns:
The current language id.

getLoginFollowUp

public string getLoginFollowUp()

Check if a follow up url exists that should be loaded after a login.

Returns:
The url to go to or null.

getMessages

public void getMessages(array Messages.)

Get all session messages.


getType

public char getType()

Returns the current session type.

This type corresponds with the account type.

Returns:
The session type.

getValue

public mixed getValue(string name)

Get a session value.

Parameters:
name - The field name.
Returns:
The value or null.

getZCShoppingCart

public mixed getZCShoppingCart()

Get the current shopping cart.

Returns:
The current zen-cart shopping cart (may be empty).

isAnonymous

public boolean isAnonymous()

Returns true if the user is not logged in at all.

This is the lowest level of identity.

Returns:
true if the current user is anonymous, false if not.

isGuest

public boolean isGuest()

Returns true if the user is a guest user.

This status level is in the middle between registered and anonymous.

Returns:
true if the current user is an guest, false if not.

isOpen

public boolean isOpen()

Check if a proper session has been started yet.

NOTE: Since this method calls session_start() internally as part of its logic, right now it can't be called twice...

Returns:
true if a session is open, false if not.

isRegistered

public boolean isRegistered()

Returns true if the user is a registered user.

This si the highest status level.

Returns:
true if the current user is registered, false if not.

isValid

public boolean isValid()

Check if the current session is valid and open.

Returns:
true if a valid session exists, false if not.

markRequestAsLoginFollowUp

public void markRequestAsLoginFollowUp()

Mark current request for return after login. /


recreate

public void recreate(boolean force)

Recreate session.

Parameters:
force - If true, force recreation of the session, even if this is disabled.

restoreCart

public void restoreCart()

Restore the shopping cart contents. /


setAccount

public void setAccount(ZMAccount account)

Set the account for the current session.

Parameters:
account - The account.

setCurrencyCode

public void setCurrencyCode(string currencyCode)

Set currency code.

Parameters:
currencyCode - The session currency code.

setLanguage

public void setLanguage(ZMLanguage language)

Set the language.

Parameters:
language - The language.

setMessages

public void setMessages(array messages)

Save the given messages in the session.

Parameters:
messages - A list of ZMMessage objects.

setValue

public void setValue(string name, mixed value)

Create a session value.

Parameters:
name - The field name.
value - The value.

ZenMagick 0.9.1