PHP Class Session, huge

Inheritance: extends CI_Session
ファイルを表示 Open project: panique/huge Class Usage Examples

Public Methods

Method Description
add ( mixed $key, mixed $value ) adds a value as a new array element to the key.
destroy ( ) deletes the session (= logs the user out)
get ( mixed $key ) : mixed gets/returns the value of a specific key of the session
init ( ) starts the session
isConcurrentSessionExists ( ) : boolean checks for session concurrency
set ( mixed $key, mixed $value ) sets a specific value to a specific key of the session
updateSessionId ( string $userId, string $sessionId = null ) : string update session id in database
userIsLoggedIn ( ) : boolean Checks if the user is logged in or not

Method Details

add() public static method

useful for collecting error messages etc
public static add ( mixed $key, mixed $value )
$key mixed
$value mixed

destroy() public static method

deletes the session (= logs the user out)
public static destroy ( )

get() public static method

gets/returns the value of a specific key of the session
public static get ( mixed $key ) : mixed
$key mixed Usually a string, right ?
return mixed the key's value or nothing

init() public static method

starts the session
public static init ( )

isConcurrentSessionExists() public static method

This is done as the following: UserA logs in with his session id('123') and it will be stored in the database. Then, UserB logs in also using the same email and password of UserA from another PC, and also store the session id('456') in the database Now, Whenever UserA performs any action, You then check the session_id() against the last one stored in the database('456'), If they don't match then log both of them out.
See also: Session::updateSessionId()
See also: http://stackoverflow.com/questions/6126285/php-stop-concurrent-user-logins
public static isConcurrentSessionExists ( ) : boolean
return boolean

set() public static method

sets a specific value to a specific key of the session
public static set ( mixed $key, mixed $value )
$key mixed key
$value mixed value

updateSessionId() public static method

update session id in database
public static updateSessionId ( string $userId, string $sessionId = null ) : string
$userId string
$sessionId string
return string

userIsLoggedIn() public static method

Checks if the user is logged in or not
public static userIsLoggedIn ( ) : boolean
return boolean user's login status