b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.10) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Class: Session

Source Location: /blogs/inc/MODEL/sessions/_session.class.php

Class Session

Class Overview

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

A sessions 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 /blogs/inc/MODEL/sessions/_session.class.php [line 57]



		
		
		
		

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 63]

The ID of the session.


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

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


[ Top ]
string   $key [line 69]

The session key (to be used in URLs).


[ Top ]
integer   $user_ID [line 76]

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


[ Top ]
array   $_data [line 93]

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 95]

[ Top ]
Methods
Constructor Session  [line 101]

  Session Session( )

Constructor



[ Top ]
dbsave  [line 401]

  void dbsave( )

Updates session data in database.

Note: The key actually only needs to be updated on a logout.



[ Top ]
delete  [line 381]

  void delete( string $param  )

Delete a value from the session data.

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


[ Top ]
get  [line 323]

  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 303]

  false|User &get_User( )

Get the attached User.



[ Top ]
has_User  [line 292]

  boolean has_User( )

Check if session has a user attached.



[ Top ]
logout  [line 270]

  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 433]

  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 353]

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

Set a data value for the session.

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 237]

  void set_User( User $User  )

Attach a User object to the session.

Parameters:
User   $User:  The user to attach


[ Top ]
set_user_ID  [line 250]

  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 ]

Documentation generated on Tue, 20 May 2008 01:45:13 +0200 by phpDocumentor 1.4.2