manager

manager is a handy little class that lets you control the user’s login status. If they have a long period of no activity, you can automatically redirect them to a login page, etc. Likewise, if they try to get sneaky and change IP addresses you can reroute them as well.

Parent Class

None


Public Properties

$settings
This associativearray contains the configuration settings to use when calling this manager instance
Data Type: array
Default Value: iPinga default settings
$newUrl
When the manager believes the user should be redirected to. An empty string for no redirect.
Data Type: string
Default Value: empty string
$isLoggedIn
Was the user logged in the last time manager checked?
Data Type: boolean
Default Value: false
$message
What was the reason the user was being redirected (assuming he was) the last time manager checked his status?
Data Type: string
Default Value: empty string
$loggedInDetails
An associative array contain the following keys: LAST_ACTIVITY, REMOTE_ADDR, USER_ID. All from the last time manager checked the user’s status
Data Type: array
Default Value: empty array

Public Methods

\ipinga\manager __construct( array $overrideSettings )
This is the class constructor. You can optionally provide an associative array to override the iPinga configuration settings
Parameters:
$overrideSettings (array: optional) associative array (key=value pairs) that override the iPinga configuration settings. Only the manager.* settings can be overridden by passing this array.
Returns:
A manager instance
Example:
void loadFromCookie()
Load the $loggedInDetails array from the iPinga cookie. This function is normally not needed outside of some the class itself.
Parameters:
None
Returns:
null
Example:
void shutdown()
Stores the $loggedInDetails array to the iPinga cookie. This function is normally not needed outside of some the class itself.
Parameters:
None
Returns:
null
Example:
void logout()
Tell manager that the user has now logged out. This function calls shutdown() as well.
Parameters:
None
Returns:
null
Example:
void update( $userId )
Tell manager that the user has now logged in. This function calls shutdown() as well. You should call this method whenever the user logs in, and also whenever the logged in user interacts with your site. ie: this is how manager knows the user has not expired/timed out.
Parameters:
$userId (mixed) is the user id you wish to store in the cookie and in the manager objects
Returns:
null
Example:
boolean userIsLoggedIn( [ boolean $redirectIfNotLoggedIn ] )
Ask manager if the user is logged in or not.
Parameters:
$redirectIfNotLoggedIn (boolean: optional) tells manager to perform a hard redirect if the user is not logged in (has expired, changed ip addresses, etc). Note: this stops the execution cold and redirects the user to the new url defined in $settings. Default: false;
Returns:
True if the user is logged in, otherwise false. Note: if $redirectIfNotLoggedIn is set to true and the user is not logged in, this function will never return to your code. False if the user is not logged in. If false, then you should check the $message for reasons why.