Tutorial Extension  1.0.0
SellerDeck Extensions - Tutorial Extension
Static Public Member Functions | Static Protected Attributes | List of all members
CSession Class Reference

Static Public Member Functions

static write ($key, $value)
 
static w ($key, $value)
 
static read ($key, $default=false, $child=false)
 
static r ($key, $default=false, $child=false)
 
static delete ($key)
 
static d ($key)
 
static dump ()
 
static start ()
 
static params ()
 
static close ()
 
static commit ()
 
static destroy ()
 

Static Protected Attributes

static $SESSION_AGE = 1800
 

Detailed Description

Definition at line 75 of file CSession.php.

Member Function Documentation

static close ( )
static

Closes the current session and releases session file lock.

Returns
boolean Returns true upon success and false upon failure.

Definition at line 274 of file CSession.php.

275  {
276  if ('' !== session_id())
277  {
278  return session_write_close();
279  }
280  return true;
281  }
static commit ( )
static

Alias for Session::close().

See also
CSession::close()
Returns
boolean Returns true upon success and false upon failure.

Definition at line 289 of file CSession.php.

290  {
291  return self::close();
292  }
static d (   $key)
static

Alias for Session::delete().

See also
CSession::delete()
Parameters
string$keyString identifying the key to delete from session data.
Returns
void
Exceptions
InvalidArgumentTypeExceptionSession key is not a string value.

Definition at line 206 of file CSession.php.

207  {
208  self::delete($key);
209  }
static delete (   $key)
static

Deletes a value from the current session data.

Parameters
string$keyString identifying the array key to delete.
Returns
void
Exceptions
InvalidArgumentTypeExceptionSession key is not a string value.

Definition at line 185 of file CSession.php.

186  {
187  if (!is_string($key))
188  {
189  $sErrorMessage = 'Session key must be string value';
190  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addError($sErrorMessage);
191  throw new InvalidArgumentTypeException($sErrorMessage);
192  }
193  self::_init();
194  unset($_SESSION[$key]);
195  self::_age();
196  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90
static destroy ( )
static

Removes session data and destroys the current session.

Returns
void

Definition at line 299 of file CSession.php.

300  {
301  if ('' !== session_id())
302  {
303  $_SESSION = array();
304 
305  // If it's desired to kill the session, also delete the session cookie.
306  // Note: This will destroy the session, and not just the session data!
307  if (ini_get("session.use_cookies"))
308  {
309  $params = session_get_cookie_params();
310  setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]
311  );
312  }
313 
314  session_destroy();
315  }
316  }
static dump ( )
static

Echos current session data.

Returns
void

Definition at line 216 of file CSession.php.

217  {
218  self::_init();
219  echo nl2br(print_r($_SESSION));
220  }
static params ( )
static

Returns current session cookie parameters or an empty array.

Returns
array Associative array of session cookie parameters.

Definition at line 259 of file CSession.php.

260  {
261  $r = array();
262  if ('' !== session_id())
263  {
264  $r = session_get_cookie_params();
265  }
266  return $r;
267  }
static r (   $key,
  $default = false,
  $child = false 
)
static

Alias for Session::read().

See also
CSession::read()
Parameters
string$keyString identifier.
mixed$defaultDefault value
boolean$childOptional child identifier for accessing array elements.
Returns
mixed Returns a string value upon success. Returns false upon failure.
Exceptions
InvalidArgumentTypeExceptionSession key is not a string value.

Definition at line 173 of file CSession.php.

174  {
175  return self::read($key, $default, $child);
176  }
static read (   $key,
  $default = false,
  $child = false 
)
static

Reads a specific value from the current session data.

Parameters
string$keyString identifier.
mixed$defaultDefault value
boolean$childOptional child identifier for accessing array elements.
Returns
mixed Returns a string value upon success. Returns false upon failure.
Exceptions
InvalidArgumentTypeExceptionSession key is not a string value.

Definition at line 132 of file CSession.php.

133  {
134  if (!is_string($key))
135  {
136  $sErrorMessage = 'Session key must be string value';
137  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addError($sErrorMessage);
138  throw new InvalidArgumentTypeException($sErrorMessage);
139  }
140  self::_init();
141  if (isset($_SESSION[$key]))
142  {
143  self::_age();
144 
145  if (false == $child)
146  {
147  return $_SESSION[$key];
148  }
149  else
150  {
151  if (isset($_SESSION[$key][$child]))
152  {
153  return $_SESSION[$key][$child];
154  }
155  }
156  }
157  else
158  {
159  return $default;
160  }
161  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90
static start ( )
static

Starts or resumes a session by calling Session::_init().

See also
CSession::_init()
Returns
boolean Returns true upon success and false upon failure.
Exceptions
SessionDisabledExceptionSessions are disabled.

Definition at line 229 of file CSession.php.

230  {
231  // this function is extraneous
232  return self::_init();
233  }
static w (   $key,
  $value 
)
static

Alias for Session::write().

See also
CSession::write()
Parameters
string$keyString identifier.
mixed$valueSingle value or array of values to be written.
Returns
mixed Value or array of values written.
Exceptions
InvalidArgumentTypeExceptionSession key is not a string value.

Definition at line 118 of file CSession.php.

119  {
120  return self::write($key, $value);
121  }
static write (   $key,
  $value 
)
static

Writes a value to the current session data.

Parameters
string$keyString identifier.
mixed$valueSingle value or array of values to be written.
Returns
mixed Value or array of values written.
Exceptions
InvalidArgumentTypeExceptionSession key is not a string value.

Definition at line 95 of file CSession.php.

96  {
97  if (!is_string($key))
98  {
99  $sErrorMessage = 'Session key must be string value';
100  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addError($sErrorMessage);
101  throw new InvalidArgumentTypeException($sErrorMessage);
102  }
103  self::_init();
104  $_SESSION[$key] = $value;
105  self::_age();
106  return $value;
107  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90

The documentation for this class was generated from the following file: