Q_Session Class
Session-related functionality
Item Index
Methods
- clear static
- clearNonce
- closeHandler static
- destroyHandler static
- gc static
- gcHandler static
- getNonce
- id static
- init static
- name static
- openHandler static
- readHandler static
- regenerateId static
- row static
- savePath static
- setNonce
- start static
- writeHandler static
Properties
- $inited static
- $nonceWasSet static
- $preventWrite static
- $sess_data static
- $session_db static
- $session_db_connection static
- $session_db_data_field static
- $session_db_duration_field static
- $session_db_id_field static
- $session_db_platform_field static
- $session_db_row static
- $session_db_row_class static
- $session_db_table static
- $session_db_updated_field static
- $session_save_path static
Methods
clear
()
static
You can call this function to clear out the contents of a session, but keep its ID.
clearNonce
()
Clears the nonce in the session ['Q']['nonce'] field and in cookie 'Q_nonce'
closeHandler
()
static
destroyHandler
-
$id
Parameters:
-
$id
String
Returns:
gc
-
$max_duration
Parameters:
-
$max_duration
Integer
gcHandler
-
$max_duration
Parameters:
-
$max_duration
Integer
getNonce
()
String
Gets nonce from the session
Returns:
id
-
[$id=null]
Parameters:
-
[$id=null]
String optionalPass a new session id, if you want to change it
Returns:
The current session id
init
()
static
name
-
[$name=null]
Parameters:
-
[$name=null]
String optional
Returns:
openHandler
-
$save_path
-
$session_name
Parameters:
-
$save_path
String -
$session_name
String
Returns:
readHandler
-
$id
Parameters:
-
$id
String
Returns:
regenerateId
-
[$destroy_old_session=false]
-
[$duration=null]
You should use this instead of simply calling session_regenerate_id(). Generates a new session id signed with "Q"/"external"/"secret", and clones the current session data into it.
Parameters:
-
[$destroy_old_session=false]
Boolean optionalSet to true if you want to get rid of the old session (to save space or for security purposes).
-
[$duration=null]
Integer | String optionalSet the duration of the regenerated session, otherwise it will use the default duration for Q_Session::durationName(). See Q/session/durations config field. Pass 0 to expire at the end of browser session.
Returns:
The new session id.
row
()
Db_Row | Null
static
Get the session Db_Row, if it has been retrieved, otherwise null
Returns:
savePath
-
[$savePath=null]
Parameters:
-
[$savePath=null]
String optional
Returns:
setNonce
-
[$overwrite=false]
Sets a nonce in the session ['Q']['nonce'] field and in cookie 'Q_nonce'
Parameters:
-
[$overwrite=false]
Boolean optionalIf true, sets a new nonce even if one is already there.
start
()
Boolean
static
Returns:
writeHandler
-
$id
-
$sess_data
Parameters:
-
$id
String -
$sess_data
String
Returns:
Properties
$inited
Boolean
protected
static
$nonceWasSet
Boolean
public
static
$preventWrite
Boolean
public
static
Set this to true to prevent writing the session to disk
$sess_data
Boolean
static
$session_db
Boolean
protected
static
$session_db_data_field
String
protected
static
$session_db_duration_field
String
protected
static
$session_db_id_field
String
protected
static
$session_db_platform_field
String
protected
static
$session_db_row_class
String
protected
static
$session_db_table
String
protected
static
$session_db_updated_field
String
protected
static
$session_save_path
String
protected
static
Events
Q/session/close
Before
Q/session/destroy
After
Event Payload:
-
id
String
Q/session/destroy
Before
Event Payload:
-
id
String
Q/session/gc
After
Event Payload:
-
id
String -
max_duration
Integer -
since_time
Integer
Q/session/gc
Before
Event Payload:
-
id
String -
max_duration
Integer
Q/session/generate
Before
This hook is called before a new session id is generated. You can return false to cancel starting the session.
Event Payload:
-
id
StringAn invalid id, if any, that was passed by the client
Q/session/id
Before
Event Payload:
-
id
String
Q/session/name
Before
Event Payload:
-
name
String
Q/session/open
After
Event Payload:
-
save_path
String -
session_name
String -
session_db_connection
Db_Interface
Q/session/open
Before
Event Payload:
-
save_path
String -
session_name
String -
session_db_connection
Db_Interface
Q/session/save
Before
Event Payload:
-
sess_data
String -
old_data
String -
existing_data
String -
merged_data
String -
changed
Boolean -
row
Db_Row
Q/session/savePath
Before
Event Payload:
-
savePath
String
Q/session/start
After
This is a hook for after the session starts. You may want to do extra security checks here.
Event Payload:
-
$original
ArrayThe userAgentInfo values that were in the session originally
-
$changed
ArrayWhether any of the userAgentInfo values changed.
-
$isNew
BooleanWhether a new session has just been started
-
$id
StringThe id of the session
Q/session/start
Before
Q/session/write
Before
Event Payload:
-
id
String -
sess_data
String -
old_data
String -
changed
Boolean
Q/session/write
After
Event Payload:
-
id
String -
changed
Boolean -
sess_data
String -
old_data
String -
existing_data
String -
merged_data
String -
data_field
String -
updated_field
String -
duration_field
String -
platform_field
String -
sess_file
String -
row
Integer