Support for session authentication and saving of authentication information between requests.
Contains the methods:
See ezcAuthenticationSessionOptions for options you can set to session objects.
Source for this file: /Authentication/src/session/authentication_session.php
Version: | //autogen// |
STATUS_EMPTY
= 1
|
The session is empty; normal behaviour is to continue with the other filters. |
STATUS_EXPIRED
= 2
|
The session expired; normal behaviour is to regenerate the session ID. |
STATUS_OK
= 0
|
Successful authentication; normal behaviour is to skip the other filters. This should be the same value as ezcAuthenticationFilter::STATUS_OK. |
protected ezcAuthenticationFilterOptions |
$options
Options for authentication filters. |
public ezcAuthenticationSession |
__construct(
[ $options
= null] )
Creates a new object of this class. |
public void |
destroy(
)
Removes the variables used by this class from the session variables. |
public ezcAuthenticationSessionOptions |
getOptions(
)
Returns the options of this class. |
public bool |
isValid(
$credentials
)
Runs through the session and returns true if the session is correct. |
public string |
load(
)
Loads the authenticated username from the session or null if it doesn't exist. |
public void |
regenerateId(
)
Regenerates the session ID. |
public int |
run(
$credentials
)
Runs through the session and returns a status code when finished. |
public void |
save(
$data
)
Saves the authenticated username and the current timestamp in the session variables. |
public void |
setOptions(
$options
)
Sets the options of this class to $options. |
public void |
start(
)
Starts the session. |
Creates a new object of this class.
Name | Type | Description |
---|---|---|
$options |
ezcAuthenticationSessionOptions | Options for this class |
Removes the variables used by this class from the session variables.
Returns the options of this class.
Runs through the session and returns true if the session is correct.
When using the session, it is often desirable to take advantage of the fact that the authenticated state of the user is kept in the session and not create and initialize the other filters (which might slow things down on every request).
The application can be structured like this:
In this way, the creation and initialization of the authentication filters is not performed if the credentials are stored in the session.
Name | Type | Description |
---|---|---|
$credentials |
ezcAuthenticationCredentials | Authentication credentials |
Loads the authenticated username from the session or null if it doesn't exist.
Regenerates the session ID.
Runs through the session and returns a status code when finished.
Name | Type | Description |
---|---|---|
$credentials |
ezcAuthenticationCredentials | Authentication credentials |
Saves the authenticated username and the current timestamp in the session variables.
Name | Type | Description |
---|---|---|
$data |
string | Information to save in the session, usually username |
Sets the options of this class to $options.
Name | Type | Description |
---|---|---|
$options |
ezcAuthenticationSessionOptions | Options for this class |
Starts the session.
This function must be called before sending any headers to the client.