Class Session
- TableAccess
- Session
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:
Handle session data of Admidio and is connected to database table adm_sessions
This class should be used together with the PHP session handling. If you create a PHP session than you should also create this session object. The class will create a recordset in adm_sessions which stores the PHP session id. With this class it should be easy to add other objects to the session and read them out if you need them elsewhere.
Class: Session
Code:
script_a.php // add a new object to the session $organization = new Organization($gDb, $organizationId); $session = new Session($gDb, $sessionId); $session->addObject('organization', $organization, true);
script_b.php // read object out of session if($session->hasObject('organization')) { $organization =& $session->getObject('organization'); } @endcode
Par: Examples
Located at session.php
Methods summary
public
|
#
__construct(
Constructor that will create an object of a recordset of the table adm_sessions. If the id is set than the specific session will be loaded. |
public
boolean
|
|
public
object|false
&
|
|
public
integer
|
#
getOrganizationId( )
Return the organization id of this session. If AutoLogin is enabled then the organization may not be the organization of the config.php because the user had set the AutoLogin to a different organization. |
public
boolean
|
|
protected
|
|
public
boolean
|
#
isValidLogin( integer $userId )
Check if the current session has a valid user login. Therefore the user id must be stored within the session and the timestamps must be valid |
public
|
|
public
|
#
refreshSession( )
Reload session data from database table adm_sessions. Refresh AutoLogin with new auto_login_id. Check renew flag and reload organization object if necessary. |
public
|
#
renewOrganizationObject( )
If you call this function than a flag is set so that all other active sessions know that they should renew the organization object. They will renew it when the user perform the next action. |
public
|
#
renewUserObject( integer $userId = 0 )
If you call this function than a flag is set so that all other active sessions know that they should renew their user object. They will renew it when the user perform the next action. |
public
boolean
|
#
save( boolean $updateFingerPrint = true )
Save all changed columns of the recordset in table of database. Therefore the class remembers if it's a new record or if only an update is necessary. The update statement will only update the changed columns. If the table has columns for creator or editor than these column with their timestamp will be updated. For new records the organization, timestamp, begin date and ip address will be set per default. |
public
|
#
setAutoLogin( )
Save all data that is necessary for an auto login. Therefore an AutoLogin object will be created with an auto_login_id and this id will be stored in a cookie in the browser of the current user. |
public
|
#
setDatabase(
Set the database object for communication with the database of this class. |
public
|
#
tableCleanup( integer $maxInactiveMinutes )
Deletes all sessions in table admSessions that are inactive since @b $maxInactiveTime minutes.. |
Methods inherited from TableAccess
__sleep()
,
clear()
,
connectAdditionalTable()
,
countAllRecords()
,
delete()
,
getValue()
,
hasColumnsValueChanged()
,
isNewRecord()
,
readData()
,
readDataByColumns()
,
readDataById()
,
setArray()
,
setValue()
Properties summary
protected
array
|
$mObjectArray
|
#
array()
|
protected
|
$mAutoLogin
|
|
protected
|
$mCookiePrefix
|
|
protected
|
$mDomain
|
Properties inherited from TableAccess
$additionalTables
,
$columnPrefix
,
$columnsInfos
,
$columnsValueChanged
,
$db
,
$dbColumns
,
$keyColumnName
,
$new_record
,
$tableName