public class Session

class.session.php #19

The Session class is a handler for all Session related logic in PHP. The functions map directly to all handler functions as defined by sessionsetsave_handler in PHP. In Symphony, this function is used in conjunction with the Cookie class. Based on: http://php.net/manual/en/function.session-set-save-handler.php#81761 by klose at openriverbed dot de which was based on http://php.net/manual/en/function.session-set-save-handler.php#79706 by maria at junkies dot jp

Methods

static boolean close()

Allows the Session to close without any further logic. Acts as a destructor function for the Session.

Returns

Always returns true

static boolean destroy(string $id)

Given a session's ID, remove it's row from tbl_sessions

Parameters
  • $id stringThe identifier for the Session to destroy

Returns

True if the Session was deleted successfully, false otherwise

static boolean gc(integer $max)

The garbage collector, which removes all empty Sessions, or any Sessions that have expired. This has a 10% chance of firing based off the gc_probability/gc_divisor.

Parameters
  • $max integerThe max session lifetime.

Returns

True on Session deletion, false if an error occurs

static string|null getDomain()

Returns the current domain for the Session to be saved to, if the installation is on localhost, this returns null and just allows PHP to take care of setting the valid domain for the Session, otherwise it will return the non-www version of the domain host.

Returns

Null if on localhost, or HTTP_HOST is not set, a string of the domain name sans www otherwise

static boolean open()

Allows the Session to open without any further logic.

Returns

Always returns true

static string read(string $id)

Given a session's ID, return it's row from tbl_sessions

Parameters
  • $id stringThe identifier for the Session to fetch

Returns

The serialised session data

static string|boolean start(integer $lifetime, string $path, string $domain, boolean $httpOnly, boolean $secure)

Starts a Session object, only if one doesn't already exist. This function maps the Session Handler functions to this classes methods by reading the default information from the PHP ini file.

Parameters
  • $lifetime integerHow long a Session is valid for, by default this is 0, which means it never expires

  • $path stringThe path the cookie is valid for on the domain

  • $domain stringThe domain this cookie is valid for

  • $httpOnly booleanWhether this cookie can be read by Javascript. By default the cookie cannot be read by Javascript

  • $secure booleanWhether this cookie should only be sent on secure servers. By default this is false, which means the cookie can be sent over HTTP and HTTPS

Returns

Returns the Session ID on success, or false on error.

See Also
static boolean write(string $id, string $data)

Given an ID, and some data, save it into tbl_sessions. This uses the ID as a unique key, and will override any existing data. If the $data is deemed to be empty, no row will be saved in the database unless there is an existing row.

Parameters
  • $id stringThe ID of the Session, usually a hash

  • $data stringThe Session information, usually a serialized object of $_SESSION[Cookie->_index]

Returns

True if the Session information was saved successfully, false otherwise

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details