Class SGL_Session

Description

Handles session management.

Typically looks like this for an admin login:

Located in /SGL/Session.php (line 81)


	
			
Variable Summary
 int $_timeout
Method Summary
 static void debug ()
 static void destroy ()
 static boolean exists ()
 static string get (string $sessVarName)
 static boolean isFirstAnonRequest ([boolean $clean = null])
 static boolean isFirstAuthenticatedRequest ([boolean $clean = null])
 static boolean isValid ()
 static boolean remove (string $sessVarName)
 static void set (string $sessVarName, mixed $sessVarValue)
 void SGL_Session ([int $uid = -1], [boolean $rememberMe = null])
 void currentUserIsOwner ( $ownerId)
 boolean dbClose ()
 boolean dbDestroy ( $sessId)
 boolean dbGc ( $max_expiry)
 boolean dbOpen ()
 string dbRead ( $sessId)
 boolean dbWrite ( $sessId,  $value)
 integer destroyUserSessions ( $uid, [ $sessId = -1])
 string getId ()
 int getRoleId ()
 integer getSessionCount ()
 int getUid ()
 int getUsername ()
 integer getUserSessionCount ( $uid, [ $sessId = -1])
 void hasAdminGui ()
 boolean hasPerms (int $permId)
 boolean isAnonymous ()
 boolean isTimedOut ()
 void runAs (mixed $runAs, [string $direction = null])
 boolean updateIdle ()
 boolean _init ([object $oUser = null], [ $rememberMe = null])
Variables
int $_timeout (line 89)

Session timeout configurable in preferences.

  • access: private
Methods
static debug (line 615)

Dumps session contents.

  • access: public
void debug ()
static destroy (line 649)

Destroys current session.

  • todo: why does session_destroy fail sometimes?
  • access: public
void destroy ()
static exists (line 297)

Determines whether a session currently exists.

  • return: true if session exists and has 1 or more elements
  • access: public
boolean exists ()
static get (line 583)

Gets specified var from session.

  • return: value of session variable
  • access: public
string get (string $sessVarName)
  • string $sessVarName: name of session var
static isFirstAnonRequest (line 942)

Detect if it is a first anonymous request to SGL.

  • access: public
boolean isFirstAnonRequest ([boolean $clean = null])
  • boolean $clean: clean first launch info about anon request
static isFirstAuthenticatedRequest (line 973)

Detect if it is a first authenticated request to SGL.

  • access: public
boolean isFirstAuthenticatedRequest ([boolean $clean = null])
  • boolean $clean: clean first launch info about auth request.
static isValid (line 310)

Determines whether the current session is valid.

  • return: true if session is valid
  • access: public
boolean isValid ()
static remove (line 563)

Removes specified var from session.

  • access: public
boolean remove (string $sessVarName)
  • string $sessVarName: name of session var
static set (line 603)

Sets specified var in session.

  • access: public
void set (string $sessVarName, mixed $sessVarValue)
  • string $sessVarName: name of session var
  • mixed $sessVarValue: value of session var
Constructor SGL_Session (line 105)

Setup session.

  • custimise session name
  • configure custom cookie params
  • setup session backed, ie, file or DB
  • start session
  • persist user object in session

  • access: public
void SGL_Session ([int $uid = -1], [boolean $rememberMe = null])
  • int $uid: user id if present
  • boolean $rememberMe: set remember me cookie
currentUserIsOwner (line 461)
void currentUserIsOwner ( $ownerId)
  • $ownerId
dbClose (line 792)

Callback method for DB session end.

boolean dbClose ()
dbDestroy (line 890)

Callback method for DB session destroy.

boolean dbDestroy ( $sessId)
  • $sessId
dbGc (line 906)

Callback method for DB session garbage collection.

boolean dbGc ( $max_expiry)
  • $max_expiry
dbOpen (line 778)

Callback method for DB session start.

boolean dbOpen ()
dbRead (line 802)

Callback method for DB session get.

  • return: return session value
string dbRead ( $sessId)
  • $sessId
dbWrite (line 846)

Callback method for DB session set.

boolean dbWrite ( $sessId,  $value)
  • $sessId
  • $value
destroyUserSessions (line 708)

Destroys all active sessions for a particular user.

If a session Id is passed, spare it from deletion. Sigh!

integer destroyUserSessions ( $uid, [ $sessId = -1])
  • $uid
  • $sessId
getGuestSessionCount (line 730)

Returns all active guest session count.

integer getGuestSessionCount ()
getId (line 631)

Returns a valid session identifier that can be used as a URL paramenter, ie SGLSESSID=1cgmq51l7jh8og8qvt0qu1ntf4

string getId ()
getMemberSessionCount (line 746)

Returns all active members session count.

integer getMemberSessionCount ()
getOrganisationId (line 544)

Returns the current user's organisation id.

  • return: the organisation id
  • access: public
int getOrganisationId ()
getRoleId (line 527)

Returns the current user's role id.

  • return: the role id
  • access: public
int getRoleId ()
getSessionCount (line 762)

Returns all active subscribed users session count.

integer getSessionCount ()
getUid (line 493)

Returns the current user's id.

  • return: the id
  • access: public
int getUid ()
getUsername (line 510)

Returns the current user's username.

  • return: the role id
  • access: public
int getUsername ()
getUserSessionCount (line 681)

Returns active session count for a particular user.

integer getUserSessionCount ( $uid, [ $sessId = -1])
  • $uid
  • $sessId
hasAdminGui (line 469)
void hasAdminGui ()
hasPerms (line 443)

Returns true if specified permission exists in the session.

  • return: if perm exists or not
  • access: public
boolean hasPerms (int $permId)
  • int $permId: the permission id
isAnonymous (line 327)

Returns true if current user is a guest (not logged in)

boolean isAnonymous ()
isTimedOut (line 393)

Determines whether the current session is timed out.

  • return: true if session is timed out
  • access: public
boolean isTimedOut ()
runAs (line 354)

Run session as specified user.

  1. SGL_Session::runAs(3); run as user with ID = 3
  2. SGL_Session::runAs(4); run as user with ID = 4
  3. SGL_Session::runAs('prev'); run as user with ID = 3 (taken fromn stack)
  4. SGL_Session::runAs(5, 'prev'); if stack is e.g. array(2, 5, 3, 6, 7) after running above command it will become array(2).

  • access: public
void runAs (mixed $runAs, [string $direction = null])
  • mixed $runAs: user ID or 'prev'
  • string $direction: only needs to be specified, when running certain session from stack
setRememberMeCookie (line 159)
void setRememberMeCookie ()
updateIdle (line 420)

Updates the idle time.

  • return: true if session idle time delayed
  • access: public
boolean updateIdle ()
_init (line 182)

Initialises session, sets some default values.

  • return: true on successful initialisation
  • access: private
boolean _init ([object $oUser = null], [ $rememberMe = null])
  • object $oUser: user object if present
  • $rememberMe

Documentation generated on Tue, 23 Feb 2010 18:14:33 +0000 by phpDocumentor 1.4.3