PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]

Class: Session

Source Location: /vendor/trax/session.php

Class Overview


Keep track of state of the client's session with the server


Author(s):

Variables

Constants

Methods



Class Details

[line 44]
Keep track of state of the client's session with the server

Since there is no continuous connection between the client and the web server, there must be some way to carry information forward from one page to the next. PHP does this with a global array variable $_SESSION which is automatically restored from an area of the server's hard disk indicated by the contents of a cookie stored on the client's computer. This class is a static class with convenience methods for accessing the contents of $_SESSION.




Tags:

tutorial:  Session


[ Top ]


Class Variables

$id =  null

[line 78]

Session ID



Tags:

static:  
access:  public

Type:   string


[ Top ]

$ip =  null

[line 66]

IP Address of client



Tags:

usedby:  Session::start()
usedby:  Session::is_valid_host()
static:  
access:  private

Type:   string


[ Top ]

$user_agent =  null

[line 72]

User Agent (OS, Browser, etc) of client



Tags:

usedby:  Session::start()
usedby:  Session::is_valid_host()
static:  
access:  private

Type:   string


[ Top ]



Class Methods


method destory_session [line 221]

void destory_session( )

Destroy the user's session

Destroy all data registered to a session




Tags:



[ Top ]

method flash [line 327]

mixed flash( mixed $key, [string $value = null])

Get or set a flash message

A flash message is a message that will appear prominently on the next screen to be sent to the user. Flash messages are intended to be shown to the user once then erased. They are stored in the $_SESSION array for the user's session.




Tags:

return:  Content of the flash message with the specified key if $value is null; otherwise null.
uses:  Session::is_valid_host()
uses:  Session::get_hash()


Parameters:

mixed   $key   Key to identify one particular flash message of potentially many for this session
string   $value   Content of the flash message if present

[ Top ]

method get [line 92]

mixed get( mixed $key)

Get a session variable

Fetch the contents from a specified element of $_SESSION




Tags:

return:  Content of the session variable with the specified key if the variable exists; otherwise null.
uses:  Session::is_valid_host()
uses:  Session::get_hash()


Parameters:

mixed   $key   Key to identify one particular session variable of potentially many for this session

[ Top ]

method get_hash [line 169]

void get_hash( )

Get key that uniquely identifies this session

Calculate a unique session key based on the session ID and user agent, plus the user's IP address if not on AOL.




Tags:

usedby:  Session::unset_var()
usedby:  Session::isset_var()
usedby:  Session::isset_flash()
usedby:  Session::flash()
usedby:  Session::unset_session()
usedby:  Session::set()
uses:  md5()
uses:  session_id()
usedby:  Session::get()
uses:  Session::is_aol_host()


[ Top ]

method isset_flash [line 297]

boolean isset_flash( mixed $key)

Test whether there is a flash message to be shown

Check whether the $_SESSION array for this session contains a flash message to be shown to the user.




Tags:

return:  
  • true => A flash message is present
  • false => No flash message is present
uses:  Session::is_valid_host()
uses:  Session::get_hash()


Parameters:

mixed   $key   Key to identify one particular flash message of potentially many for this session

[ Top ]

method isset_var [line 271]

boolean isset_var( mixed $key)

Test whether a session variable is defined in $_SESSION

Check the $_SESSION array for the existance of a variable identified by $key




Tags:

return:  
  • true => The specified session variable is defined.
  • false => The specified session variable is not defined.
uses:  Session::is_valid_host()
uses:  Session::get_hash()


Parameters:

mixed   $key   Key to identify one particular session variable of potentially many for this session

[ Top ]

method is_aol_host [line 152]

boolean is_aol_host( )

Test whether the client is an AOL user

Check whether the domain name of the client's IP ends in "proxy.aol.com" or the client's user agent name includes "AOL"




Tags:

return:  
  • true => Client is on AOL
  • false => Client from some other ISP
usedby:  Session::get_hash()
usedby:  Session::is_valid_host()


[ Top ]

method is_valid_host [line 133]

boolean is_valid_host( )

Test whether the user host is as expected for this session

Compare the REMOTE_ADDR and HTTP_USER_AGENT elements of $_SERVER to the expected values for this session.




Tags:

return:  
  • true => User host is as expected
  • false => User host NOT as expected
usedby:  Session::unset_var()
usedby:  Session::isset_var()
usedby:  Session::isset_flash()
usedby:  Session::flash()
usedby:  Session::start()
usedby:  Session::set()
uses:  Session::is_aol_host()
uses:  Session::$user_agent
usedby:  Session::get()
uses:  Session::$ip


[ Top ]

method set [line 112]

void set( mixed $key, string $value)

Set a session variable

Store a value in a specified element of $_SESSION




Tags:



Parameters:

mixed   $key   Key to identify one particular session variable of potentially many for this session
string   $value   Value to store in the session variable identified by $key

[ Top ]

method start [line 188]

void start( )

Start or continue a session



Tags:



[ Top ]

method unset_session [line 231]

void unset_session( )

Free all session variables currently registered



Tags:



[ Top ]

method unset_var [line 244]

void unset_var( mixed $key)

Unset a session variable

Unset the variable in $_SESSION identified by key $key




Tags:



[ Top ]


Class Constants

TRAX_SESSION_LIFETIME =  "0"

[line 54]

Lifetime in seconds of cookie or, if 0, until browser is restarted.


[ Top ]

TRAX_SESSION_MAXLIFETIME_MINUTES =  "20"

[line 60]

After this number of minutes, stored data will be seen as 'garbage' and cleaned up by the garbage collection process.


[ Top ]

TRAX_SESSION_NAME =  "TRAXSESSID"

[line 49]

Name of the session (used as cookie name).


[ Top ]



Documentation generated on Thu, 04 May 2006 19:47:54 -0600 by phpDocumentor 1.3.0RC4