Abstract class Phalcon\Session\Adapter¶
implements Phalcon\Session\AdapterInterface
Base class for Phalcon\Session adapters
Constants¶
integer SESSION_ACTIVE
integer SESSION_NONE
integer SESSION_DISABLED
Methods¶
public __construct ([array $options])
Phalcon\Session\Adapter constructor
public start ()
Starts the session (if headers are already sent the session will not be started)
public setOptions (array $options)
Sets session's options
public getOptions ()
Get internal options
public setName (mixed $name)
Set session name
public getName ()
Get session name
public regenerateId ([mixed $deleteOldSession])
public get (mixed $index, [mixed $defaultValue], [mixed $remove])
Gets a session variable from an application context
public set (mixed $index, mixed $value)
Sets a session variable in an application context
public has (mixed $index)
Check whether a session variable is set in an application context
public remove (mixed $index)
Removes a session variable from an application context
public getId ()
Returns active session id
public setId (mixed $id)
Set the current session id
public isStarted ()
Check whether the session has been started
public destroy ([mixed $removeData])
Destroys the active session
public status ()
Returns the status of the current session.
<?php
var_dump(
$session->status()
);
if ($session->status() !== $session::SESSION_ACTIVE) {
$session->start();
}
public __get (mixed $index)
Alias: Gets a session variable from an application context
public __set (mixed $index, mixed $value)
Alias: Sets a session variable in an application context
public __isset (mixed $index)
Alias: Check whether a session variable is set in an application context
public __unset (mixed $index)
Alias: Removes a session variable from an application context
public __destruct ()
...
protected removeSessionData ()
...
Class Phalcon\Session\Adapter\Files¶
extends abstract class Phalcon\Session\Adapter
implements Phalcon\Session\AdapterInterface
Constants¶
integer SESSION_ACTIVE
integer SESSION_NONE
integer SESSION_DISABLED
Methods¶
public __construct ([array $options]) inherited from Phalcon\Session\Adapter
Phalcon\Session\Adapter constructor
public start () inherited from Phalcon\Session\Adapter
Starts the session (if headers are already sent the session will not be started)
public setOptions (array $options) inherited from Phalcon\Session\Adapter
Sets session's options
public getOptions () inherited from Phalcon\Session\Adapter
Get internal options
public setName (mixed $name) inherited from Phalcon\Session\Adapter
Set session name
public getName () inherited from Phalcon\Session\Adapter
Get session name
public regenerateId ([mixed $deleteOldSession]) inherited from Phalcon\Session\Adapter
public get (mixed $index, [mixed $defaultValue], [mixed $remove]) inherited from Phalcon\Session\Adapter
Gets a session variable from an application context
public set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Sets a session variable in an application context
public has (mixed $index) inherited from Phalcon\Session\Adapter
Check whether a session variable is set in an application context
public remove (mixed $index) inherited from Phalcon\Session\Adapter
Removes a session variable from an application context
public getId () inherited from Phalcon\Session\Adapter
Returns active session id
public setId (mixed $id) inherited from Phalcon\Session\Adapter
Set the current session id
public isStarted () inherited from Phalcon\Session\Adapter
Check whether the session has been started
public destroy ([mixed $removeData]) inherited from Phalcon\Session\Adapter
Destroys the active session
public status () inherited from Phalcon\Session\Adapter
Returns the status of the current session.
<?php
var_dump(
$session->status()
);
if ($session->status() !== $session::SESSION_ACTIVE) {
$session->start();
}
public __get (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Gets a session variable from an application context
public __set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Alias: Sets a session variable in an application context
public __isset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Check whether a session variable is set in an application context
public __unset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Removes a session variable from an application context
public __destruct () inherited from Phalcon\Session\Adapter
...
protected removeSessionData () inherited from Phalcon\Session\Adapter
...
Class Phalcon\Session\Adapter\Libmemcached¶
extends abstract class Phalcon\Session\Adapter
implements Phalcon\Session\AdapterInterface
This adapter store sessions in libmemcached
<?php
use Phalcon\Session\Adapter\Libmemcached;
$session = new Libmemcached(
[
"servers" => [
[
"host" => "localhost",
"port" => 11211,
"weight" => 1,
],
],
"client" => [
\Memcached::OPT_HASH => \Memcached::HASH_MD5,
\Memcached::OPT_PREFIX_KEY => "prefix.",
],
"lifetime" => 3600,
"prefix" => "my_",
]
);
$session->start();
$session->set("var", "some-value");
echo $session->get("var");
Constants¶
integer SESSION_ACTIVE
integer SESSION_NONE
integer SESSION_DISABLED
Methods¶
public getLibmemcached ()
...
public getLifetime ()
...
public __construct (array $options)
Phalcon\Session\Adapter\Libmemcached constructor
public open ()
...
public close ()
...
public read (mixed $sessionId)
public write (mixed $sessionId, mixed $data)
public destroy ([mixed $sessionId])
public gc ()
public start () inherited from Phalcon\Session\Adapter
Starts the session (if headers are already sent the session will not be started)
public setOptions (array $options) inherited from Phalcon\Session\Adapter
Sets session's options
public getOptions () inherited from Phalcon\Session\Adapter
Get internal options
public setName (mixed $name) inherited from Phalcon\Session\Adapter
Set session name
public getName () inherited from Phalcon\Session\Adapter
Get session name
public regenerateId ([mixed $deleteOldSession]) inherited from Phalcon\Session\Adapter
public get (mixed $index, [mixed $defaultValue], [mixed $remove]) inherited from Phalcon\Session\Adapter
Gets a session variable from an application context
public set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Sets a session variable in an application context
public has (mixed $index) inherited from Phalcon\Session\Adapter
Check whether a session variable is set in an application context
public remove (mixed $index) inherited from Phalcon\Session\Adapter
Removes a session variable from an application context
public getId () inherited from Phalcon\Session\Adapter
Returns active session id
public setId (mixed $id) inherited from Phalcon\Session\Adapter
Set the current session id
public isStarted () inherited from Phalcon\Session\Adapter
Check whether the session has been started
public status () inherited from Phalcon\Session\Adapter
Returns the status of the current session.
<?php
var_dump(
$session->status()
);
if ($session->status() !== $session::SESSION_ACTIVE) {
$session->start();
}
public __get (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Gets a session variable from an application context
public __set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Alias: Sets a session variable in an application context
public __isset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Check whether a session variable is set in an application context
public __unset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Removes a session variable from an application context
public __destruct () inherited from Phalcon\Session\Adapter
...
protected removeSessionData () inherited from Phalcon\Session\Adapter
...
Class Phalcon\Session\Adapter\Memcache¶
extends abstract class Phalcon\Session\Adapter
implements Phalcon\Session\AdapterInterface
This adapter store sessions in memcache
<?php
use Phalcon\Session\Adapter\Memcache;
$session = new Memcache(
[
"uniqueId" => "my-private-app",
"host" => "127.0.0.1",
"port" => 11211,
"persistent" => true,
"lifetime" => 3600,
"prefix" => "my_",
]
);
$session->start();
$session->set("var", "some-value");
echo $session->get("var");
Constants¶
integer SESSION_ACTIVE
integer SESSION_NONE
integer SESSION_DISABLED
Methods¶
public getMemcache ()
...
public getLifetime ()
...
public __construct ([array $options])
Phalcon\Session\Adapter\Memcache constructor
public open ()
...
public close ()
...
public read (mixed $sessionId)
public write (mixed $sessionId, mixed $data)
public destroy ([mixed $sessionId])
public gc ()
public start () inherited from Phalcon\Session\Adapter
Starts the session (if headers are already sent the session will not be started)
public setOptions (array $options) inherited from Phalcon\Session\Adapter
Sets session's options
public getOptions () inherited from Phalcon\Session\Adapter
Get internal options
public setName (mixed $name) inherited from Phalcon\Session\Adapter
Set session name
public getName () inherited from Phalcon\Session\Adapter
Get session name
public regenerateId ([mixed $deleteOldSession]) inherited from Phalcon\Session\Adapter
public get (mixed $index, [mixed $defaultValue], [mixed $remove]) inherited from Phalcon\Session\Adapter
Gets a session variable from an application context
public set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Sets a session variable in an application context
public has (mixed $index) inherited from Phalcon\Session\Adapter
Check whether a session variable is set in an application context
public remove (mixed $index) inherited from Phalcon\Session\Adapter
Removes a session variable from an application context
public getId () inherited from Phalcon\Session\Adapter
Returns active session id
public setId (mixed $id) inherited from Phalcon\Session\Adapter
Set the current session id
public isStarted () inherited from Phalcon\Session\Adapter
Check whether the session has been started
public status () inherited from Phalcon\Session\Adapter
Returns the status of the current session.
<?php
var_dump(
$session->status()
);
if ($session->status() !== $session::SESSION_ACTIVE) {
$session->start();
}
public __get (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Gets a session variable from an application context
public __set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Alias: Sets a session variable in an application context
public __isset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Check whether a session variable is set in an application context
public __unset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Removes a session variable from an application context
public __destruct () inherited from Phalcon\Session\Adapter
...
protected removeSessionData () inherited from Phalcon\Session\Adapter
...
Class Phalcon\Session\Adapter\Redis¶
extends abstract class Phalcon\Session\Adapter
implements Phalcon\Session\AdapterInterface
This adapter store sessions in Redis
<?php
use Phalcon\Session\Adapter\Redis;
$session = new Redis(
[
"uniqueId" => "my-private-app",
"host" => "localhost",
"port" => 6379,
"auth" => "foobared",
"persistent" => false,
"lifetime" => 3600,
"prefix" => "my",
"index" => 1,
]
);
$session->start();
$session->set("var", "some-value");
echo $session->get("var");
Constants¶
integer SESSION_ACTIVE
integer SESSION_NONE
integer SESSION_DISABLED
Methods¶
public getRedis ()
...
public getLifetime ()
...
public __construct ([array $options])
Phalcon\Session\Adapter\Redis constructor
public open ()
public close ()
public read (mixed $sessionId)
public write (mixed $sessionId, mixed $data)
public destroy ([mixed $sessionId])
public gc ()
public start () inherited from Phalcon\Session\Adapter
Starts the session (if headers are already sent the session will not be started)
public setOptions (array $options) inherited from Phalcon\Session\Adapter
Sets session's options
public getOptions () inherited from Phalcon\Session\Adapter
Get internal options
public setName (mixed $name) inherited from Phalcon\Session\Adapter
Set session name
public getName () inherited from Phalcon\Session\Adapter
Get session name
public regenerateId ([mixed $deleteOldSession]) inherited from Phalcon\Session\Adapter
public get (mixed $index, [mixed $defaultValue], [mixed $remove]) inherited from Phalcon\Session\Adapter
Gets a session variable from an application context
public set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Sets a session variable in an application context
public has (mixed $index) inherited from Phalcon\Session\Adapter
Check whether a session variable is set in an application context
public remove (mixed $index) inherited from Phalcon\Session\Adapter
Removes a session variable from an application context
public getId () inherited from Phalcon\Session\Adapter
Returns active session id
public setId (mixed $id) inherited from Phalcon\Session\Adapter
Set the current session id
public isStarted () inherited from Phalcon\Session\Adapter
Check whether the session has been started
public status () inherited from Phalcon\Session\Adapter
Returns the status of the current session.
<?php
var_dump(
$session->status()
);
if ($session->status() !== $session::SESSION_ACTIVE) {
$session->start();
}
public __get (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Gets a session variable from an application context
public __set (mixed $index, mixed $value) inherited from Phalcon\Session\Adapter
Alias: Sets a session variable in an application context
public __isset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Check whether a session variable is set in an application context
public __unset (mixed $index) inherited from Phalcon\Session\Adapter
Alias: Removes a session variable from an application context
public __destruct () inherited from Phalcon\Session\Adapter
...
protected removeSessionData () inherited from Phalcon\Session\Adapter
...
Interface Phalcon\Session\AdapterInterface¶
Methods¶
abstract public start ()
...
abstract public setOptions (array $options)
...
abstract public getOptions ()
...
abstract public get (mixed $index, [mixed $defaultValue])
...
abstract public set (mixed $index, mixed $value)
...
abstract public has (mixed $index)
...
abstract public remove (mixed $index)
...
abstract public getId ()
...
abstract public isStarted ()
...
abstract public destroy ([mixed $removeData])
...
abstract public regenerateId ([mixed $deleteOldSession])
...
abstract public setName (mixed $name)
...
abstract public getName ()
...
Class Phalcon\Session\Bag¶
implements Phalcon\Di\InjectionAwareInterface, Phalcon\Session\BagInterface, IteratorAggregate, Traversable, ArrayAccess, Countable
This component helps to separate session data into "namespaces". Working by this way you can easily create groups of session variables into the application
Methods¶
public __construct (mixed $name)
Phalcon\Session\Bag constructor
public setDI (Phalcon\DiInterface $dependencyInjector)
Sets the DependencyInjector container
public getDI ()
Returns the DependencyInjector container
public initialize ()
Initializes the session bag. This method must not be called directly, the class calls it when its internal data is accessed
public destroy ()
Destroys the session bag
public set (mixed $property, mixed $value)
Sets a value in the session bag
public __set (mixed $property, mixed $value)
Magic setter to assign values to the session bag
public get (mixed $property, [mixed $defaultValue])
Obtains a value from the session bag optionally setting a default value
public __get (mixed $property)
Magic getter to obtain values from the session bag
public has (mixed $property)
Check whether a property is defined in the internal bag
public __isset (mixed $property)
Magic isset to check whether a property is defined in the bag
public remove (mixed $property)
Removes a property from the internal bag
public __unset (mixed $property)
Magic unset to remove items using the array syntax
final public count ()
Return length of bag
final public getIterator ()
Returns the bag iterator
final public offsetSet (mixed $property, mixed $value)
...
final public offsetExists (mixed $property)
...
final public offsetUnset (mixed $property)
...
final public offsetGet (mixed $property)
...
Interface Phalcon\Session\BagInterface¶
Methods¶
abstract public initialize ()
...
abstract public destroy ()
...
abstract public set (mixed $property, mixed $value)
...
abstract public get (mixed $property, [mixed $defaultValue])
...
abstract public has (mixed $property)
...
abstract public __set (mixed $property, mixed $value)
...
abstract public __get (mixed $property)
...
abstract public __isset (mixed $property)
...
Class Phalcon\Session\Exception¶
extends class Phalcon\Exception
implements Throwable
Methods¶
final private Exception __clone () inherited from Exception
Clone the exception
public __construct ([mixed $message], [mixed $code], [mixed $previous]) inherited from Exception
Exception constructor
public __wakeup () inherited from Exception
...
final public string getMessage () inherited from Exception
Gets the Exception message
final public int getCode () inherited from Exception
Gets the Exception code
final public string getFile () inherited from Exception
Gets the file in which the exception occurred
final public int getLine () inherited from Exception
Gets the line in which the exception occurred
final public array getTrace () inherited from Exception
Gets the stack trace
final public Exception getPrevious () inherited from Exception
Returns previous Exception
final public Exception getTraceAsString () inherited from Exception
Gets the stack trace as a string
public string __toString () inherited from Exception
String representation of the exception
Class Phalcon\Session\Factory¶
extends abstract class Phalcon\Factory
implements Phalcon\FactoryInterface
Loads Session Adapter class using 'adapter' option
<?php
use Phalcon\Session\Factory;
$options = [
"uniqueId" => "my-private-app",
"host" => "127.0.0.1",
"port" => 11211,
"persistent" => true,
"lifetime" => 3600,
"prefix" => "my_",
"adapter" => "memcache",
];
$session = Factory::load($options);
Methods¶
public static load (Phalcon\Config | array $config)
protected static loadClass (mixed $namespace, mixed $config) inherited from Phalcon\Factory
...