Show:

Q_Session Class

Module: Q

Session-related functionality

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
)
Boolean static

Parameters:

  • $id String

Returns:

Boolean:

gc

(
  • $max_duration
)
static

Parameters:

  • $max_duration Integer

gcHandler

(
  • $max_duration
)
static

Parameters:

  • $max_duration Integer

getNonce

() String

Gets nonce from the session

Returns:

String:

id

(
  • [$id=null]
)
String static

Parameters:

  • [$id=null] String optional

    Pass a new session id, if you want to change it

Returns:

String:

The current session id

init

() static

name

(
  • [$name=null]
)
String static

Parameters:

  • [$name=null] String optional

Returns:

String:

openHandler

(
  • $save_path
  • $session_name
)
Boolean static

Parameters:

  • $save_path String
  • $session_name String

Returns:

Boolean:

readHandler

(
  • $id
)
String static

Parameters:

  • $id String

Returns:

String:

regenerateId

(
  • [$destroy_old_session=false]
  • [$duration=null]
)
String static

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 optional

    Set to true if you want to get rid of the old session (to save space or for security purposes).

  • [$duration=null] Integer | String optional

    Set 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:

String:

The new session id.

row

() Db_Row | Null static

Get the session Db_Row, if it has been retrieved, otherwise null

Returns:

Db_Row | Null:

savePath

(
  • [$savePath=null]
)
String static

Parameters:

  • [$savePath=null] String optional

Returns:

String:

setNonce

(
  • [$overwrite=false]
)

Sets a nonce in the session ['Q']['nonce'] field and in cookie 'Q_nonce'

Parameters:

  • [$overwrite=false] Boolean optional

    If true, sets a new nonce even if one is already there.

start

() Boolean static

Returns:

Boolean:

writeHandler

(
  • $id
  • $sess_data
)
Boolean static

Parameters:

  • $id String
  • $sess_data String

Returns:

Boolean:

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_connection

Db 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

Db_Row 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 String

    An 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/read

After

Event Payload:

Q/session/read

Before

Event Payload:

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 Array

    The userAgentInfo values that were in the session originally

  • $changed Array

    Whether any of the userAgentInfo values changed.

  • $isNew Boolean

    Whether a new session has just been started

  • $id String

    The 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