phpDocumentor sessions
[ class tree: sessions ] [ index: sessions ] [ all elements ]

Class: Session

Source Location: /qp_inc/sessions/model/_session.class.php

Class Session

Class Overview

A session tracks a given user (not necessarily logged in) while he's navigating the site.

A session also stores data for the length of the session.

Sessions are tracked with a cookie containing the session ID. The cookie also contains a random key to prevent sessions hacking.

Located in /qp_inc/sessions/model/_session.class.php [line 56]



		
		
		
		

Properties

Methods

[ Top ]
Property Summary
integer   $ID   The ID of the session.
boolean   $is_validated   Is the session validated? This means that it was created from a received cookie.
string   $key   The session key (to be used in URLs).
integer   $user_ID   The user ID for the user of the session (NULL for anonymous (not logged in) user).
array   $_data   Data stored for the session.
mixed   $_session_needs_save  

[ Top ]
Method Summary
Session   Session()   Constructor
void   dbsave()   Updates session data in database.
void   delete()   Delete a value from the session data.
mixed   get()   Get a data value for the session. This checks for the data to be expired and unsets it then.
false|User   &get_User()   Get the attached User.
boolean   has_User()   Check if session has a user attached.
void   logout()   Logout the user, by invalidating the session key and unsetting $user_ID.
void   reload_data()   Reload session data.
void   set()   Set a data value for the session.
void   set_User()   Attach a User object to the session.
void   set_user_ID()   Attach a user ID to the session.

[ Top ]
Properties
integer   $ID [line 62]

The ID of the session.


[ Top ]
boolean   $is_validated = false [line 82]

Is the session validated? This means that it was created from a received cookie.


[ Top ]
string   $key [line 68]

The session key (to be used in URLs).


[ Top ]
integer   $user_ID [line 75]

The user ID for the user of the session (NULL for anonymous (not logged in) user).


[ Top ]
array   $_data [line 92]

Data stored for the session.

This holds an array( expire, value ) for each data item key.

API Tags:
Access:  protected


[ Top ]
mixed   $_session_needs_save = false [line 94]

[ Top ]
Methods
Constructor Session  [line 103]

  Session Session( )

Constructor

If valid session cookie received: pull session from DB Otherwise, INSERT a session into DB



[ Top ]
dbsave  [line 415]

  void dbsave( )

Updates session data in database.

NOTE: Debuglog additions will may not be displayed since the debuglog may alreayd have been displayed (shutdown function)



[ Top ]
delete  [line 395]

  void delete( string $param  )

Delete a value from the session data.

Parameters:
string   $param:  Name of the data's key.


[ Top ]
get  [line 335]

  mixed get( string $param, [mixed $default = NULL]  )

Get a data value for the session. This checks for the data to be expired and unsets it then.

Parameters:
string   $param:  Name of the data's key.
mixed   $default:  Default value to use if key is not set or has expired. (since 1.10.0)

API Tags:
Return:  The value, if set; otherwise $default


[ Top ]
get_User  [line 315]

  false|User &get_User( )

Get the attached User.



[ Top ]
has_User  [line 304]

  boolean has_User( )

Check if session has a user attached.



[ Top ]
logout  [line 282]

  void logout( )

Logout the user, by invalidating the session key and unsetting $user_ID.

We want to keep the user in the session log, but we're unsetting $user_ID, which refers to the current session.

Because the session key is invalid/broken, on the next request a new session will be started.

NOTE: we MIGHT want to link subsequent sessions together if we want to keep track...



[ Top ]
reload_data  [line 463]

  void reload_data( )

Reload session data.

This is needed if the running process waits for a child process to write data into the Session, e.g. the captcha plugin in test mode waiting for the Debuglog output from the process that created the image (included through an IMG tag).



[ Top ]
set  [line 367]

  void set( string $param, mixed $value, [integer $expire = 0]  )

Set a data value for the session.

Updated values get saved to the DB automatically on shutdown, in shutdown().

Parameters:
string   $param:  Name of the data's key.
mixed   $value:  The value
integer   $expire:  Time in seconds for data to expire (0 to disable).


[ Top ]
set_User  [line 235]

  void set_User( User $User  )

Attach a User object to the session.

Parameters:
User   $User:  The user to attach


[ Top ]
set_user_ID  [line 248]

  void set_user_ID( integer $user_ID  )

Attach a user ID to the session.

NOTE: ID gets saved to DB on shutdown. This may be a "problem" when querying T_sessions for sess_user_ID.

Parameters:
integer   $user_ID:  The ID of the user to attach


[ Top ]