Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions

Session Class Reference

Inheritance diagram for Session:
Collaboration diagram for Session:

List of all members.

Static Public Member Functions

static init ()
static create ()
static cookie ($data, $expiration=null)
static read ()
static shutdown ()
static write ()
static destroy ()
static gc ()
static set_userid ($user_id)
static clear_userid ($user_id)
static add_to_set ($set, $value, $key=null)
static notice ($notice, $key=null)
static error ($error, $key=null)
static get_set ($set, $clear=true)
static get_notices ($clear=true)
static get_notice ($key, $clear=true)
static get_errors ($clear=true)
static get_error ($key, $clear=true)
static remove_notice ($key)
static remove_error ($key)
static messages_get ($clear=true, $callback=null)
static messages_out ($clear=true, $callback=null)
static has_messages ()
static has_errors ($key=null)
static cache_limiter ($type= 'nocache')
static session_data_hash ()
static changed ()
static queue ($fn, $name=null)
static process_queue ()

Public Attributes

const HABARI_SESSION_COOKIE_NAME = 'habari_session'

Static Public Attributes

static $write_queue = array()
static $session_id
static $session_changed = false
static $stored_session_hash

Static Protected Member Functions

static get_subnet ($remote_address= '')

Detailed Description

Habari Session class

Manages sessions for the PHP session routines

Definition at line 15 of file session.php.


Member Function Documentation

static Session::add_to_set ( set,
value,
key = null 
) [static]

Adds a value to a session set

Parameters:
string $set Name of the set
mixed $value value to store
string $key Optional unique key for the set under which to store the value

Definition at line 324 of file session.php.

Referenced by AdminHandler::__construct(), error(), and notice().

static Session::cache_limiter ( type = 'nocache'  )  [static]
static Session::changed (  )  [static]

Determine if the session data has changed

Returns:
bool True if the session data has changed

Definition at line 627 of file session.php.

Referenced by write().

static Session::clear_userid ( user_id  )  [static]

Clear the user_id attached to sessions, delete other sessions that are associated to the user_id

Parameters:
integer $user_id The user_id to clear.

Definition at line 309 of file session.php.

Referenced by User::forget().

static Session::cookie ( data,
expiration = null 
) [static]

Sends the Habari session cookie to the browser with the given payload and expiration.

Parameters:
string $data Whatever should be in the body of the cookie. Probably, you know, a Session ID.
null|int $expiration The exact value to put in the expiration field of the cookie. Use null and we'll calculate one based on the session lifetime.

Definition at line 101 of file session.php.

Referenced by create(), destroy(), and read().

static Session::create (  )  [static]

Create a new session - that is, generate an ID and set the session cookie

Definition at line 87 of file session.php.

Referenced by cache_limiter(), cookie(), and write().

static Session::destroy (  )  [static]

Destroy stored session data by session id

Definition at line 260 of file session.php.

Referenced by User::forget().

static Session::error ( error,
key = null 
) [static]
static Session::gc (  )  [static]

Session garbage collection deletes expired sessions

Definition at line 283 of file session.php.

static Session::get_error ( key,
clear = true 
) [static]

Retrieve a specific error from stored errors.

Parameters:
string $key ID of the error to retrieve
boolean $clear true to clear the error from the session upon receipt
Returns:
string Return the error message

Definition at line 428 of file session.php.

static Session::get_errors ( clear = true  )  [static]

Get all error messages from the user session

Parameters:
boolean $clear true to clear the messages from the session upon receipt
Returns:
array And array of error messages

Definition at line 416 of file session.php.

Referenced by get_error(), and messages_get().

static Session::get_notice ( key,
clear = true 
) [static]

Retrieve a specific notice from stored errors.

Parameters:
string $key ID of the notice to retrieve
boolean $clear true to clear the notice from the session upon receipt
Returns:
string Return the notice message

Definition at line 398 of file session.php.

static Session::get_notices ( clear = true  )  [static]

Get all notice messages from the user session

Parameters:
boolean $clear true to clear the messages from the session upon receipt
Returns:
array And array of notice messages

Definition at line 386 of file session.php.

Referenced by get_notice(), and messages_get().

static Session::get_set ( set,
clear = true 
) [static]

Return a set of messages

Parameters:
string $set The name of the message set
boolean $clear true to clear the messages from the session upon receipt
Returns:
array An array of message strings

Definition at line 366 of file session.php.

Referenced by AdminHandler::__construct(), get_errors(), and get_notices().

static Session::get_subnet ( remote_address = ''  )  [static, protected]

Helper function to find the Class A, B, or C subnet of the given IP address.

We use this to store subnets for each IPv4 session, rather than distinct IPs, which could be pooled or rotated on large networks.

Parameters:
string $remote_address The remote host's IP address.
Returns:
int|string The numeric subnet, if IPv4. The complete address, as passed, if a valid IPv6.

Definition at line 541 of file session.php.

Referenced by read().

static Session::has_errors ( key = null  )  [static]

Determine if there are error messages to display

Parameters:
string $key Optional key of the unique error message
Returns:
boolean true if there are errors, false if not

Definition at line 523 of file session.php.

Referenced by HiEngineParser::hi_command().

static Session::has_messages (  )  [static]

Determine if there are messages that should be displayed Messages are not cleared when calling this function.

Returns:
boolean true if there are messages to display.

Definition at line 512 of file session.php.

Referenced by HiEngineParser::hi_command().

static Session::init (  )  [static]

Initialize the session handlers

Definition at line 32 of file session.php.

static Session::messages_get ( clear = true,
callback = null 
) [static]

Return output of notice and error messages

Parameters:
boolean $clear true to clear the messages from the session upon receipt
array $callback a reference to a callback function for formatting the the messages or the string 'array' to get a raw array
Returns:
mixed output of messages

Definition at line 474 of file session.php.

Referenced by messages_out(), and AdminGroupsHandler::update_groups().

static Session::messages_out ( clear = true,
callback = null 
) [static]

Output notice and error messages

Parameters:
bool $clear true to clear the messages from the session upon receipt
null|callable $callback A reference to a callback function for formatting the messages

Definition at line 501 of file session.php.

Referenced by HiEngineParser::hi_command().

static Session::notice ( notice,
key = null 
) [static]
static Session::process_queue (  )  [static]

Call update() on QueryRecords or execute the function queued with self::queue()

Definition at line 659 of file session.php.

static Session::queue ( fn,
name = null 
) [static]

Add objects or functions to the post-processing queue, executed via self::process_queue()

Parameters:
QueryRecord|Callable $fn A QueryRecord to call ->update() on, or a function to execute
null|string $name An index to save the queue under, defaults to the SPL object hash for objects

Definition at line 640 of file session.php.

Referenced by Post::field_save(), Block::field_save(), User::field_save(), and ControlStorage::from_storage_string().

static Session::read (  )  [static]

Read session data from the database and load it into the $_SESSION global. Verifies against a number of parameters for security purposes.

Returns:
bool Whether a session was loaded or not

Definition at line 121 of file session.php.

Referenced by init().

static Session::remove_error ( key  )  [static]

Removes a specific error from the stored errors.

Parameters:
string $key ID of the error to remove
Returns:
boolean True or false depending if the error was removed successfully.

Definition at line 458 of file session.php.

Referenced by AdminHandler::__construct(), and get_error().

static Session::remove_notice ( key  )  [static]

Removes a specific notice from the stored notices.

Parameters:
string $key ID of the notice to remove
Returns:
boolean True or false depending if the notice was removed successfully.

Definition at line 446 of file session.php.

Referenced by get_notice().

static Session::session_data_hash (  )  [static]

Get a hash of the contents of the session data for change comparison

Returns:
string a hash of the session data

Definition at line 615 of file session.php.

Referenced by changed(), and init().

static Session::set_userid ( user_id  )  [static]

Sets the user_id attached to the current session

Parameters:
integer $user_id The user id of the current user

Definition at line 297 of file session.php.

Referenced by User::remember().

static Session::write (  )  [static]

Commit $_SESSION data to the database for this user.

Definition at line 216 of file session.php.


The documentation for this class was generated from the following file: