\myMVC_HttpSession

Class to manage the sessions.

It supports normal session (managed from PHP) or database ones. Session-ID can be as URL-parameter or as Cookie. See mymvc.php for configuration items

Summary

Methods
Properties
Constants
__destruct()
shutdown()
getInstance()
isExpired()
getSessionId()
destroy()
useNamespace()
emptyNamespace()
emptyGivenNamespace()
set()
setInNamespace()
delete()
deleteFromNamespace()
get()
getFromNamespace()
exists()
existsInNamespace()
No public properties found
No constants found
startNewSession()
No protected properties found
N/A
__construct()
$currentNamespace
$instance
$dbEngine
$sessionData
N/A

Properties

$currentNamespace

$currentNamespace : 

Type

$instance

$instance : 

Type

$dbEngine

$dbEngine : 

Type

$sessionData

$sessionData : 

Type

Methods

__destruct()

__destruct() 

Destructor.

Saves the data in the session or the database, depending on the value of $config['SESSION_TYPE'] (see mymvc.php)

shutdown()

shutdown() 

Called from PHP if the script terminates with exit()

getInstance()

getInstance() : \myMVC_HttpSession

Returns the instance of this class.

Returns

\myMVC_HttpSession

An instance of the session class

isExpired()

isExpired() : boolean

Returns if the current session is expired

Returns

boolean —

true if the session is expired,

                           false if it's active

getSessionId()

getSessionId() : string

Returns the current session ID

Returns

string —

The SessionID

destroy()

destroy() 

Destroy the current Session (for example due to a logout) and starts a new one.

useNamespace()

useNamespace(string  $namespace) 

Set the namespace to use

Parameters

string $namespace

The namespace to be used

emptyNamespace()

emptyNamespace() 

Empty the current used namespace

emptyGivenNamespace()

emptyGivenNamespace(string  $namespace) 

Empty a given namespace

Parameters

string $namespace

Namespace to be deleted

set()

set(string  $key, object  $value) 

Save an object in the current namespace

Parameters

string $key

Name of the variable

object $value

Object to be saved

setInNamespace()

setInNamespace(string  $namespace, string  $key, object  $value) 

Save an object in the given namespace

Parameters

string $namespace

Namespace to be used for saving

string $key

Name of the variable

object $value

Object to be saved

delete()

delete(string  $key) 

Delete an object from current namespace

Parameters

string $key

Name of the variable

deleteFromNamespace()

deleteFromNamespace(string  $namespace, string  $key) 

Delete an object from the given namespace

Parameters

string $namespace

Namespace to be used for deleting

string $key

Name of the variable

get()

get(string  $key) : object

Returns a previously saved object in the current namespace

Parameters

string $key

Name of the variable

Returns

object —

Value

getFromNamespace()

getFromNamespace(string  $namespace, string  $key) : object

Returns a previously saved object in the given namespace

Parameters

string $namespace

Namespace to be used for get

string $key

Name of the variable

Returns

object —

Value

exists()

exists(string  $key) : boolean

Returns whether an object exists in the current namespace

Parameters

string $key

Name of the variable

Returns

boolean —

true if exists, false otherwise

existsInNamespace()

existsInNamespace(string  $namespace, string  $key) : boolean

Returns whether an object exists in the given namespace

Parameters

string $namespace

Namespace to be used for get

string $key

Name of the variable

Returns

boolean —

true if exists, false otherwise

startNewSession()

startNewSession() 

Starts a new session.

Lifetime in seconds and type (URL or Cookies) can be set in the configuration ($config['SESSION_LIFETIME'] and $config['SESSION_USECOOKIES']). Default are 8 hours for lifetime and URL for session

__construct()

__construct() 

Constructor.

WARNING: This class has to be used as Singleton! Example:

$session = myMVC_HttpSession::getInstance();