ePages 6.10 - DE_EPAGES/Presentation/API/Session.pm

Package DE_EPAGES::Presentation::API::Session

This package provides the interface for sessions, session ids and session attributes. The TLE variable #Session implemented by DE_EPAGES::Presentation::API::TLE::SessionHandler provides access to session attributes from the TLE language. Note that #Session is undefined if the user is not logged on and does not have a basket yet. The following list shows all pre-defined session attributes.

Additional session attributes can be created with the function SetSessionAttribute.

@EXPORT_OK
GenerateSessionID
InsertSession
ExistsSessionAttribute
GetSessionAttribute
SetSessionAttribute
GetSessionAttributes
IsSessionTimedOut
GetSessionAge

Functions

ExistsSessionAttribute
GenerateSessionID
GetSessionAge
GetSessionAttribute
GetSessionAttributes
InsertSession
IsSessionTimedOut
SetSessionAttribute

ExistsSessionAttribute

Returns true if a session attribute exists.

Syntax
$Exists = ExistsSessionAttribute($Name);
Input
$Name (string)
name of session attribute
Return
$Exists (boolean)
exists attribute

GenerateSessionID

Generates a new, unique session id. The session id is not automatically registered in the database. See also InsertSession.

Syntax
$SessionID = GenerateSessionID( $Address, $Port )
Example
$SessionID = GenerateSessionID( '12.34.56.78', 10047 )
Input
$Address (int)
application server IP address or '0.0.0.0' (optional) | string
$Port | application server port (optional)
Return
$SessionID (string)
a new session id

GetSessionAge

Get the number of minutes since creation of the session.

Syntax
GetSessionAge($IntSessionID);
Input
$IntSessionID (int)
internal session id
Return
$minutes (integer)
age of the session in minutes

GetSessionAttribute

Returns a session attribute value.

Syntax
$Value = GetSessionAttribute( $IntSessionID, $Name )
Input
$IntSessionID (int)
internal session id
$Name (string)
name of session attribute
Output
$Value (string)
session parameter

GetSessionAttributes

Returns all session attribute values.

Syntax
$aValues = GetSessionAttributes()
Output
$aValues (reference to array)
session attributes values

InsertSession

Generates a new session id for a user and saves it in the database. If you have access to a servlet object, use $Servlet->registerSession($User, $PerCookie) instead of InsertSession(). See: DE_EPAGES::Presentation::Servlet::Permission::registerSession

Syntax
$SessionID = InsertSession($User, $PerCookie);
Input
$User (object)
user (optional)
$PerCookie (bit)
user identified by cookie (optional)
Return
$SessionID (string)
a new session id

IsSessionTimedOut

Check if a session has timed out, that is, at least as many minutes as the session timeout have gone since session creation.

Syntax
$IsTimeout = IsSessionTimedOut($IntSessionID)
if (IsSessionTimedOut($IntSessionID)) { ... }
Input
$IntSessionID (int)
internal session id
Return
$IsTimeout (boolean)
true if the session has timed out

SetSessionAttribute

Sets a session attribute value.

Syntax
SetSessionAttribute( $IntSessionID, $Name, $Value )
Input
$IntSessionID (int)
internal session id
$Name (string)
name of session attribute
$Value (string)
session parameter