Session\Adapter\AbstractAdapter
AbstractSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Phalcon\Session\Adapter\AbstractAdapter— implementsSessionHandlerInterface
Uses Phalcon\Storage\Adapter\AdapterInterface · SessionHandlerInterface
Method Summary
publicboolclose()Closepublicbooldestroy( mixed$id )Destroypublicint|falsegc( int$max_lifetime )Garbage Collectorpublicboolopen(mixed$path,mixed$name)Openpublicstringread( mixed$id )Readpublicboolwrite(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
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 GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Adapter\Exceptions\AdapterRuntimeError
Uses Phalcon\Session\Exception
Session\Adapter\Exceptions\InvalidSavePath
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Adapter\Exceptions\InvalidSavePath
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Adapter\Exceptions\SavePathUnavailable
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
\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-’ ]
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
Uses SessionHandlerInterface
Method Summary
publicboolclose()Closepublicbooldestroy( mixed$id )Destroypublicint|falsegc( int$max_lifetime )Garbage Collectorpublicboolopen(mixed$path,mixed$name)Openpublicstringread( mixed$id )Readpublicboolwrite(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
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\Storage\AdapterFactory
Method Summary
Methods
__construct()
public function __construct(
AdapterFactory $factory,
array $options = []
);Constructor
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 adapterpublicboolwrite(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
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\InvalidSessionNamePhalcon\Session\Exceptions\SessionAlreadyStartedPhalcon\Session\Exceptions\SessionModificationDenied
Session\Exceptions\InvalidSessionAdapter
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\InvalidSessionAdapter
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Exceptions\InvalidSessionName
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\InvalidSessionName
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Exceptions\SessionAlreadyStarted
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
\ExceptionPhalcon\Session\ExceptionPhalcon\Session\Exceptions\SessionAlreadyStarted
Uses Phalcon\Session\Exception
Method Summary
Methods
__construct()
public function __construct();Session\Exceptions\SessionModificationDenied
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
\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\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 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.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 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.
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.