SessionInterface

Extends IteratorAggregate

Interface defining a Joomla! Session object

since

2.0.0

package

Joomla Framework

Methods

abort

Aborts the current session

abort() : bool
see session_abort()
since

2.0.0

Response

bool

all

Retrieves all variables from the session store

all() : array
since

2.0.0

Response

array

clear

Clears all variables from the session store

clear() : void
since

2.0.0

close

Writes session data and ends session

close() : void

Session data is usually stored after your script terminated without the need to call SessionInterface::close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.

see session_write_close()
since

2.0.0

destroy

Frees all session variables and destroys all data registered to a session

destroy() : bool

This method resets the $_SESSION variable and destroys all of the data associated with the current session in its storage (file or DB). It forces new session to be started after this method is called. It does not unset the session cookie.

see session_destroy() session_unset()
since

2.0.0

Response

bool

fork

Create a new session and copy variables from the old one

fork() : bool
since

2.0.0

Response

bool

gc

Perform session data garbage collection

gc() : int|bool
see session_gc()
since

2.0.0

Response

int|boolNumber of deleted sessions on success or boolean false on failure or if the function is unsupported

get

Get data from the session store

get(string name, mixed default = null) : mixed
since

2.0.0

Arguments

name

stringName of a variable

default

mixedDefault value of a variable if not set

Response

mixedValue of a variable

getExpire

Get expiration time in seconds

getExpire() : int
since

2.0.0

Response

intThe session expiration time in seconds

getId

Get the session ID

getId() : string
since

2.0.0

Response

stringThe session ID

getName

Get the session name

getName() : string
since

2.0.0

Response

stringThe session name

getToken

Get a session token.

getToken(bool forceNew = false) : string

Tokens are used to secure forms from spamming attacks. Once a token has been generated the system will check the request to see if it is present, if not it will invalidate the session.

since

2.0.0

Arguments

forceNew

boolIf true, forces a new token to be created

Response

string

has

Check whether data exists in the session store

has(string name) : bool
since

2.0.0

Arguments

name

stringName of variable

Response

boolTrue if the variable exists

hasToken

Check if the session has the given token.

hasToken(string token, bool forceExpire = true) : bool
since

2.0.0

Arguments

token

stringHashed token to be verified

forceExpire

boolIf true, expires the session

Response

bool

isActive

Check if the session is active

isActive() : bool
since

2.0.0

Response

bool

isNew

Check whether this session is newly created

isNew() : bool
since

2.0.0

Response

bool

isStarted

Check if the session is started

isStarted() : bool
since

2.0.0

Response

bool

remove

Unset a variable from the session store

remove(string name) : mixed
since

2.0.0

Arguments

name

stringName of variable

Response

mixedThe value from session or NULL if not set

restart

Restart an expired or locked session

restart() : bool
see destroy
since

2.0.0

Response

boolTrue on success

set

Set data into the session store

set(string name, mixed value = null) : mixed
since

2.0.0

Arguments

name

stringName of a variable.

value

mixedValue of a variable.

Response

mixedOld value of a variable.

setId

Set the session ID

setId(string id) : $this
since

2.0.0

Arguments

id

stringThe session ID

Response

$this

setName

Set the session name

setName(string name) : $this
since

2.0.0

Arguments

name

stringThe session name

Response

$this

start

Start a session

start() : void
since

2.0.0