Session\Adapter\AbstractAdapter
AbstractSource on GitHubPhalcon\Session\Adapter\AbstractAdapter— implementsSessionHandlerInterface,SessionUpdateTimestampHandlerInterface
Uses Phalcon\Storage\Adapter\AdapterInterface · SessionHandlerInterface · SessionUpdateTimestampHandlerInterface
Method Summary
publicboolclose()Closepublicbooldestroy( mixed$id )Destroypublicint|falsegc( int$max_lifetime )Garbage Collectorpublicboolopen(mixed$path,mixed$name)Openpublicstringread( mixed$id )ReadpublicboolupdateTimestamp(mixed$id,mixed$data)Refresh the session lifetime without changing the session datapublicboolvalidateId( mixed$id )Validate the session id (used when strict mode is enabled)publicboolwrite(mixed$id,mixed$data)WriteprotectedmixedgetArrVal(array$collection,mixed$index,mixed$defaultValue = null)@todo Remove this when we get traitsProperties
protectedAdapterInterface$adapterMethods
close()
public function close(): bool;Close
destroy()
public function destroy( mixed $id ): bool;Destroy
gc()
public function gc( int $max_lifetime ): int|false;Garbage Collector
open()
public function open(
mixed $path,
mixed $name
): bool;Open
read()
public function read( mixed $id ): string;Read
updateTimestamp()
public function updateTimestamp(
mixed $id,
mixed $data
): bool;Refresh the session lifetime without changing the session data
validateId()
public function validateId( mixed $id ): bool;Validate the session id (used when strict mode is enabled)
write()
public function write(
mixed $id,
mixed $data
): bool;Write
getArrVal()
protected function getArrVal(
array $collection,
mixed $index,
mixed $defaultValue = null
): mixed;@todo Remove this when we get traits
Session\Adapter\Exceptions\AdapterRuntimeError
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Adapter\Exceptions\AdapterRuntimeError
Uses Phalcon\Session\Exception
Session\Adapter\Exceptions\InvalidSavePath
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Adapter\Exceptions\InvalidSavePath
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Adapter\Exceptions\SavePathUnavailable
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Adapter\Exceptions\SavePathUnavailable
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct( string $path );Session\Adapter\Libmemcached
ClassSource on GitHubPhalcon\Session\Adapter\Libmemcached
Phalcon\Session\Adapter\AbstractAdapterPhalcon\Session\Adapter\Libmemcached
Uses Phalcon\Storage\AdapterFactory
Method Summary
Methods
__construct()
public function __construct(
AdapterFactory $factory,
array $options = []
);Libmemcached constructor.
] ], ‘defaultSerializer’ => ‘Php’, ‘lifetime’ => 3600, ‘serializer’ => null, ‘prefix’ => ‘sess-memc-’, ‘stripPrefix’ => false ]
Session\Adapter\Noop
ClassSource on GitHubPhalcon\Session\Adapter\Noop
This is an “empty” or null adapter. It can be used for testing or any other purpose that no session needs to be invoked
<?php
use Phalcon\Session\Manager;
use Phalcon\Session\Adapter\Noop;
$session = new Manager();
$session->setAdapter(new Noop());Phalcon\Session\Adapter\Noop— implementsSessionHandlerInterface,SessionUpdateTimestampHandlerInterface
Uses SessionHandlerInterface · SessionUpdateTimestampHandlerInterface
Method Summary
publicboolclose()Closepublicbooldestroy( mixed$id )Destroypublicint|falsegc( int$max_lifetime )Garbage Collectorpublicboolopen(mixed$path,mixed$name)Openpublicstringread( mixed$id )ReadpublicboolupdateTimestamp(mixed$id,mixed$data)Refresh the session lifetime without changing the session datapublicboolvalidateId( mixed$id )Validate the session id (used when strict mode is enabled)publicboolwrite(mixed$id,mixed$data)WriteMethods
close()
public function close(): bool;Close
destroy()
public function destroy( mixed $id ): bool;Destroy
gc()
public function gc( int $max_lifetime ): int|false;Garbage Collector
open()
public function open(
mixed $path,
mixed $name
): bool;Open
read()
public function read( mixed $id ): string;Read
updateTimestamp()
public function updateTimestamp(
mixed $id,
mixed $data
): bool;Refresh the session lifetime without changing the session data
validateId()
public function validateId( mixed $id ): bool;Validate the session id (used when strict mode is enabled)
write()
public function write(
mixed $id,
mixed $data
): bool;Write
Session\Adapter\Redis
ClassSource on GitHubPhalcon\Session\Adapter\Redis
Phalcon\Session\Adapter\AbstractAdapterPhalcon\Session\Adapter\Redis
Uses Phalcon\Session\Adapter\Exceptions\AdapterRuntimeError · Phalcon\Storage\AdapterFactory
Method Summary
public__construct(AdapterFactory$factory,array$options = [])Constructorpublicboolclose()Close - releases the session lock if one is heldpublicbooldestroy( mixed$id )Destroypublicstringread( mixed$id )ReadprotectedboolacquireLock( mixed$id )Tries to acquire the session lock, pausing lockWaitTime microsecondsprotectedvoidreleaseLock()Releases the session lock - only when this instance still owns itProperties
protectedbool$lockAcquired = falseprotectedint$lockExpiry = 30Lock time-to-live in seconds. The lock is not refreshed during the request: a request that runs longer than this expiry loses its lock silently and a concurrent request may then acquire it (the token-guarded release still avoids deleting the newer lock). Raise this above the longest expected request to retain the lock for the whole request.protectedstring$lockKey = ""protectedint$lockRetries = 100protectedstring$lockToken = ""protectedint$lockWaitTime = 50000protectedbool$lockingEnabled = falseprotectedstring$prefix = ""Methods
__construct()
public function __construct(
AdapterFactory $factory,
array $options = []
);Constructor
close()
public function close(): bool;Close - releases the session lock if one is held
destroy()
public function destroy( mixed $id ): bool;Destroy
read()
public function read( mixed $id ): string;Read
acquireLock()
protected function acquireLock( mixed $id ): bool;Tries to acquire the session lock, pausing lockWaitTime microseconds
between attempts, up to lockRetries times
releaseLock()
protected function releaseLock(): void;Releases the session lock - only when this instance still owns it
Session\Adapter\Stream
ClassSource on GitHubPhalcon\Session\Adapter\Stream
This is the file based adapter. It stores sessions in a file based system
<?php
use Phalcon\Session\Manager;
use Phalcon\Session\Adapter\Stream;
$session = new Manager();
$files = new Stream(
[
'savePath' => '/tmp',
]
);
$session->setAdapter($files);@property array $options @property string $prefix @property string $path
Phalcon\Session\Adapter\NoopPhalcon\Session\Adapter\Stream
Uses Phalcon\Session\Adapter\Exceptions\AdapterRuntimeError · Phalcon\Session\Adapter\Exceptions\InvalidSavePath · Phalcon\Session\Adapter\Exceptions\SavePathUnavailable
Method Summary
public__construct( array$options = [] )Constructorpublicbooldestroy( mixed$id )publicint|falsegc( int$max_lifetime )Garbage Collectorpublicboolopen(mixed$path,mixed$name)Ignore the savePath and use local defined pathpublicstringread( mixed$id )Reads data from the adapterpublicboolupdateTimestamp(mixed$id,mixed$data)Refresh the session file modification time without changing its datapublicboolvalidateId( mixed$id )Validate the session id (used when strict mode is enabled)publicboolwrite(mixed$id,mixed$data)protectedmixedgetArrVal(array$collection,mixed$index,mixed$defaultValue = null,string$cast = null)@todo Remove this when we get traitsprotectedarray|falsegetGlobFiles( string$pattern )Gets the glob array or returns false on failureprotectedstringgetPrefixedName( mixed$name )Helper method to get the name prefixedprotectedphpFileExists( string$filename )@link https://php.net/manual/en/function.file-exists.phpprotectedphpFileGetContents( string$filename )@link https://php.net/manual/en/function.file-get-contents.phpprotectedphpFilePutContents(string$filename,mixed$data,int$flags = 0,mixed$context = null)@link https://php.net/manual/en/function.file-put-contents.phpprotectedphpFopen(string$filename,string$mode)@link https://php.net/manual/en/function.fopen.phpprotectedstringphpIniGet( string$varname )Gets the value of a configuration optionprotectedboolphpIsWritable( string$filename )Tells whether the filename is writableProperties
protectedarray$options = []Session optionsprotectedstring$prefix = ""Session prefixMethods
__construct()
public function __construct( array $options = [] );Constructor
destroy()
public function destroy( mixed $id ): bool;gc()
public function gc( int $max_lifetime ): int|false;Garbage Collector
open()
public function open(
mixed $path,
mixed $name
): bool;Ignore the savePath and use local defined path
read()
public function read( mixed $id ): string;Reads data from the adapter
updateTimestamp()
public function updateTimestamp(
mixed $id,
mixed $data
): bool;Refresh the session file modification time without changing its data
validateId()
public function validateId( mixed $id ): bool;Validate the session id (used when strict mode is enabled)
write()
public function write(
mixed $id,
mixed $data
): bool;getArrVal()
protected function getArrVal(
array $collection,
mixed $index,
mixed $defaultValue = null,
string $cast = null
): mixed;@todo Remove this when we get traits
getGlobFiles()
protected function getGlobFiles( string $pattern ): array|false;Gets the glob array or returns false on failure
getPrefixedName()
protected function getPrefixedName( mixed $name ): string;Helper method to get the name prefixed
phpFileExists()
protected function phpFileExists( string $filename );@link https://php.net/manual/en/function.file-exists.php
phpFileGetContents()
protected function phpFileGetContents( string $filename );@link https://php.net/manual/en/function.file-get-contents.php
phpFilePutContents()
protected function phpFilePutContents(
string $filename,
mixed $data,
int $flags = 0,
mixed $context = null
);@link https://php.net/manual/en/function.file-put-contents.php
phpFopen()
protected function phpFopen(
string $filename,
string $mode
);@link https://php.net/manual/en/function.fopen.php
phpIniGet()
protected function phpIniGet( string $varname ): string;Gets the value of a configuration option
@link https://php.net/manual/en/function.ini-get.php @link https://php.net/manual/en/ini.list.php
phpIsWritable()
protected function phpIsWritable( string $filename ): bool;Tells whether the filename is writable
@link https://php.net/manual/en/function.is-writable.php
Session\Bag
ClassSource on GitHubPhalcon\Session\Bag
This component helps to separate session data into “namespaces”. Working by this way you can easily create groups of session variables into the application
$user = new \Phalcon\Session\Bag("user");
$user->name = "Kimbra Johnson";
$user->age = 22;@property DiInterface|null $container @property string $name @property ManagerInterface $session;
Phalcon\Support\CollectionPhalcon\Session\Bag— implementsPhalcon\Session\BagInterface,Phalcon\Di\InjectionAwareInterface
Uses Phalcon\Di\Di · Phalcon\Di\DiInterface · Phalcon\Di\InjectionAwareInterface · Phalcon\Session\ManagerInterface · Phalcon\Support\Collection
Method Summary
public__construct(ManagerInterface$session,string$name)publicvoidclear()Destroys the session bagpublicDiInterfacegetDI()Returns the DependencyInjector containerpublicvoidinit( array$data = [] )Initialize internal arraypublicvoidremove( string$element )Removes a property from the internal bagpublicvoidset(string$element,mixed$value)Sets a value in the session bagpublicvoidsetDI( DiInterface$container )Sets the DependencyInjector containerMethods
__construct()
public function __construct(
ManagerInterface $session,
string $name
);clear()
public function clear(): void;Destroys the session bag
getDI()
public function getDI(): DiInterface;Returns the DependencyInjector container
init()
public function init( array $data = [] ): void;Initialize internal array
remove()
public function remove( string $element ): void;Removes a property from the internal bag
set()
public function set(
string $element,
mixed $value
): void;Sets a value in the session bag
setDI()
public function setDI( DiInterface $container ): void;Sets the DependencyInjector container
Session\BagInterface
InterfaceSource on GitHubPhalcon\Session\BagInterface
Interface for Phalcon\Session\Bag
Phalcon\Session\BagInterface
Method Summary
publicmixed__get( string$element )publicbool__isset( string$element )publicvoid__set(string$element,mixed$value)publicvoid__unset( string$element )publicvoidclear()publicmixedget(string$element,mixed$defaultValue = null,string$cast = null)publicboolhas( string$element )publicvoidinit( array$data = [] )publicvoidremove( string$element )publicvoidset(string$element,mixed$value)Methods
__get()
public function __get( string $element ): mixed;__isset()
public function __isset( string $element ): bool;__set()
public function __set(
string $element,
mixed $value
): void;__unset()
public function __unset( string $element ): void;clear()
public function clear(): void;get()
public function get(
string $element,
mixed $defaultValue = null,
string $cast = null
): mixed;has()
public function has( string $element ): bool;init()
public function init( array $data = [] ): void;remove()
public function remove( string $element ): void;set()
public function set(
string $element,
mixed $value
): void;Session\Exception
ClassSource on GitHubPhalcon\Session\Exception
Exceptions thrown in Phalcon\Session will use this class
\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Adapter\Exceptions\AdapterRuntimeErrorPhalcon\Session\Adapter\Exceptions\InvalidSavePathPhalcon\Session\Adapter\Exceptions\SavePathUnavailablePhalcon\Session\Exceptions\InvalidSessionAdapterPhalcon\Session\Exceptions\InvalidSessionIdPhalcon\Session\Exceptions\InvalidSessionNamePhalcon\Session\Exceptions\SessionAlreadyStartedPhalcon\Session\Exceptions\SessionModificationDenied
Session\Exceptions\InvalidSessionAdapter
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\InvalidSessionAdapter
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Exceptions\InvalidSessionId
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\InvalidSessionId
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Exceptions\InvalidSessionName
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\InvalidSessionName
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Exceptions\SessionAlreadyStarted
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\SessionAlreadyStarted
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Exceptions\SessionModificationDenied
ClassSource on GitHub\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\SessionModificationDenied
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Manager
ClassSource on GitHub@property SessionHandlerInterface|null $adapter @property string $name @property array $options @property string $uniqueId
stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Session\Manager— implementsPhalcon\Session\ManagerInterface
Uses InvalidArgumentException · Phalcon\Di\AbstractInjectionAware · Phalcon\Di\DiInterface · Phalcon\Session\Exceptions\InvalidSessionAdapter · Phalcon\Session\Exceptions\InvalidSessionId · Phalcon\Session\Exceptions\InvalidSessionName · Phalcon\Session\Exceptions\SessionAlreadyStarted · Phalcon\Session\Exceptions\SessionModificationDenied · SessionHandlerInterface
Method Summary
public__construct( array$options = [] )Manager constructor.publicmixed__get( string$key )Alias: Gets a session variable from an application contextpublicbool__isset( string$key )Alias: Check whether a session variable is set in an application contextpublicvoid__set(string$key,mixed$value)Alias: Sets a session variable in an application contextpublicvoid__unset( string$key )Alias: Removes a session variable from an application contextpublicvoiddestroy()Destroy/end a sessionpublicboolexists()Check whether the session has been startedpublicmixedget(string$key,mixed$defaultValue = null,bool$remove = false)Gets a session variable from an application contextpublicSessionHandlerInterface|nullgetAdapter()Returns the stored session adapterpublicstringgetId()Returns the session idpublicstringgetName()Returns the name of the sessionpublicarraygetOptions()Get internal optionspublicboolhas( string$key )Check whether a session variable is set in an application contextpublicManagerInterfaceregenerateId( bool$deleteOldSession = true )Regenerates the session id via session_regenerate_id() (when thepublicvoidremove( string$key )Removes a session variable from an application contextpublicvoidset(string$key,mixed$value)Sets a session variable in an application contextpublicManagerInterfacesetAdapter( SessionHandlerInterface$adapter )Set the adapter for the sessionpublicManagerInterfacesetId( string$sessionId )Set session IdpublicManagerInterfacesetName( string$name )Set the session name. Throw exception if the session has startedpublicvoidsetOptions( array$options )Sets session's optionspublicboolstart()Starts the session (if headers are already sent the session will not bepublicintstatus()Returns the status of the current session.protectedboolphpHeadersSent()Checks if or where headers have been sentMethods
__construct()
public function __construct( array $options = [] );Manager constructor.
__get()
public function __get( string $key ): mixed;Alias: Gets a session variable from an application context
__isset()
public function __isset( string $key ): bool;Alias: Check whether a session variable is set in an application context
__set()
public function __set(
string $key,
mixed $value
): void;Alias: Sets a session variable in an application context
__unset()
public function __unset( string $key ): void;Alias: Removes a session variable from an application context
destroy()
public function destroy(): void;Destroy/end a session
exists()
public function exists(): bool;Check whether the session has been started
get()
public function get(
string $key,
mixed $defaultValue = null,
bool $remove = false
): mixed;Gets a session variable from an application context
getAdapter()
public function getAdapter(): SessionHandlerInterface|null;Returns the stored session adapter
getId()
public function getId(): string;Returns the session id
getName()
public function getName(): string;Returns the name of the session
getOptions()
public function getOptions(): array;Get internal options
has()
public function has( string $key ): bool;Check whether a session variable is set in an application context
regenerateId()
public function regenerateId( bool $deleteOldSession = true ): ManagerInterface;Regenerates the session id via session_regenerate_id() (when the
session is active). The registered save handler persists the data
under the new id.
remove()
public function remove( string $key ): void;Removes a session variable from an application context
set()
public function set(
string $key,
mixed $value
): void;Sets a session variable in an application context
setAdapter()
public function setAdapter( SessionHandlerInterface $adapter ): ManagerInterface;Set the adapter for the session
setId()
public function setId( string $sessionId ): ManagerInterface;Set session Id
setName()
public function setName( string $name ): ManagerInterface;Set the session name. Throw exception if the session has started and do not allow poop names
setOptions()
public function setOptions( array $options ): void;Sets session’s options
start()
public function start(): bool;Starts the session (if headers are already sent the session will not be started)
status()
public function status(): int;Returns the status of the current session.
phpHeadersSent()
protected function phpHeadersSent(): bool;Checks if or where headers have been sent
@link https://php.net/manual/en/function.headers-sent.php
Session\ManagerInterface
InterfaceSource on GitHubPhalcon\Session
Interface for the Phalcon\Session\Manager
Phalcon\Session\ManagerInterface
Uses InvalidArgumentException · SessionHandlerInterface
Method Summary
publicmixed__get( string$key )Alias: Gets a session variable from an application contextpublicbool__isset( string$key )Alias: Check whether a session variable is set in an application contextpublicvoid__set(string$key,mixed$value)Alias: Sets a session variable in an application contextpublicvoid__unset( string$key )Alias: Removes a session variable from an application contextpublicvoiddestroy()Destroy/end a sessionpublicboolexists()Check whether the session has been startedpublicmixedget(string$key,mixed$defaultValue = null,bool$remove = false)Gets a session variable from an application contextpublicSessionHandlerInterface|nullgetAdapter()Returns the stored session adapterpublicstringgetId()Returns the session idpublicstringgetName()Returns the name of the sessionpublicarraygetOptions()Get internal optionspublicboolhas( string$key )Check whether a session variable is set in an application contextpublicManagerInterfaceregenerateId( bool$deleteOldSession = true )Regenerates the session id using the adapter.publicvoidremove( string$key )Removes a session variable from an application contextpublicvoidset(string$key,mixed$value)Sets a session variable in an application contextpublicManagerInterfacesetAdapter( SessionHandlerInterface$adapter )Set the adapter for the sessionpublicManagerInterfacesetId( string$sessionId )Set session IdpublicManagerInterfacesetName( string$name )Set the session name. Throw exception if the session has startedpublicvoidsetOptions( array$options )Sets session's optionspublicboolstart()Starts the session (if headers are already sent the session will not bepublicintstatus()Returns the status of the current session.Constants
intSESSION_ACTIVE = 2intSESSION_DISABLED = 0intSESSION_NONE = 1Methods
__get()
public function __get( string $key ): mixed;Alias: Gets a session variable from an application context
__isset()
public function __isset( string $key ): bool;Alias: Check whether a session variable is set in an application context
__set()
public function __set(
string $key,
mixed $value
): void;Alias: Sets a session variable in an application context
__unset()
public function __unset( string $key ): void;Alias: Removes a session variable from an application context
destroy()
public function destroy(): void;Destroy/end a session
exists()
public function exists(): bool;Check whether the session has been started
get()
public function get(
string $key,
mixed $defaultValue = null,
bool $remove = false
): mixed;Gets a session variable from an application context
getAdapter()
public function getAdapter(): SessionHandlerInterface|null;Returns the stored session adapter
getId()
public function getId(): string;Returns the session id
getName()
public function getName(): string;Returns the name of the session
getOptions()
public function getOptions(): array;Get internal options
has()
public function has( string $key ): bool;Check whether a session variable is set in an application context
regenerateId()
public function regenerateId( bool $deleteOldSession = true ): ManagerInterface;Regenerates the session id using the adapter.
remove()
public function remove( string $key ): void;Removes a session variable from an application context
set()
public function set(
string $key,
mixed $value
): void;Sets a session variable in an application context
setAdapter()
public function setAdapter( SessionHandlerInterface $adapter ): ManagerInterface;Set the adapter for the session
setId()
public function setId( string $sessionId ): ManagerInterface;Set session Id
setName()
public function setName( string $name ): ManagerInterface;Set the session name. Throw exception if the session has started and do not allow poop names
setOptions()
public function setOptions( array $options ): void;Sets session’s options
start()
public function start(): bool;Starts the session (if headers are already sent the session will not be started)
status()
public function status(): int;Returns the status of the current session.