\MySessionHandler

A class to handle the current session. This class holds the name of the session and the user ID associated with it.

The class is used to sign in and sign out clients from the system

Be sure to have a session_start() at the beginning AND before this class's instanciation.

Summary

Methods
Properties
Constants
__construct()
challengeSession()
isSignedIn()
signOut()
signIn()
getUserID()
getUser()
No public properties found
SESSION_NAME
DEFAULT_SIGNIN_PAGE
SESSION_UID
SESSION_USERNAME
No protected methods found
No protected properties found
N/A
No private methods found
$userID
N/A

Constants

SESSION_NAME

SESSION_NAME

DEFAULT_SIGNIN_PAGE

DEFAULT_SIGNIN_PAGE

SESSION_UID

SESSION_UID

SESSION_USERNAME

SESSION_USERNAME

Properties

$userID

$userID : 

Type

Methods

__construct()

__construct() 

Creates a new session with the given name.

Checks if the given session name is active, and if so, grabs the user id.

challengeSession()

challengeSession(  $defaultSignInPage = \MySessionHandler::DEFAULT_SIGNIN_PAGE) 

Checks if the current session is registered (via isSignedIn()).

If not, changes the header to the default sign-in page.

Parameters

$defaultSignInPage

A page to redirect to if the session challenge fails.

isSignedIn()

isSignedIn() : false

Checks if this sessions name is registered.

Returns

false —

if not registered, else true

signOut()

signOut() 

Signs a user out. Returns nothing.

signIn()

signIn(  $challengePassword,   $userObj) 

Sign a user in, if the session does not already exist.

A challenge password must be provided along with the user's id and password from the system to compare with. If success, session is created.

Before calling this function, use the username to determine which user is trying to sign-in. Once found, call this function to now verify the password, and subsequently set the session.

Parameters

$challengePassword

A password typed in by the user (a regular word string, not encrypted)

$userObj

getUserID()

getUserID() : \The

Often the user's id is required to check privileges etc.

Use this to get the ID registered for this session

Returns

\The —

user ID as a numerical value.

getUser()

getUser(  $dbhandle) : \A

Retrieve the User currently in the session.

Parameters

$dbhandle

Returns

\A —

user object