Phalcon会话
Session\Adapter\AbstractAdapter
GitHub上的源码
-
命名空间
-
使用
Phalcon\Storage\Adapter\AdapterInterface
SessionHandlerInterface
-
继承
-
实现
该文件是Phalcon框架的一部分。
(c) Phalcon团队team@phalcon.io
对于完整的版权和许可信息,请查看随此源代码分发的LICENSE文件。
属性
/**
* @var AdapterInterface
*/
protected $adapter;
方法
public function close(): bool;
关闭 public function destroy( mixed $id ): bool;
销毁 public function gc( int $max_lifetime ): int | false;
垃圾回收器 public function open( mixed $path, mixed $name ): bool;
打开 public function read( mixed $id ): string;
读取 public function write( mixed $id, mixed $data ): bool;
写入 protected function getArrVal( array $collection, mixed $index, mixed $defaultValue = null ): mixed;
@todo 当我们获得特性时,删除这个 Session\Adapter\Libmemcached
GitHub上的源码
-
命名空间
-
使用
Phalcon\Storage\AdapterFactory
-
继承
AbstractAdapter
-
实现
Phalcon\Session\Adapter\Libmemcached
方法
public function __construct( AdapterFactory $factory, array $options = [] );
Libmemcached构造函数。 Session\Adapter\Noop
GitHub上的源码
Phalcon\Session\Adapter\Noop
这是一个“空”或空适配器。它可以用于测试或任何其他不需要调用会话的目的
<?php
use Phalcon\Session\Manager;
use Phalcon\Session\Adapter\Noop;
$session = new Manager();
$session->setAdapter(new Noop());
属性
/**
* The connection of some adapters
*
* @var null
*/
protected $connection;
/**
* Session options
*
* @var array
*/
protected $options;
/**
* Session prefix
*
* @var string
*/
protected $prefix = ;
/**
* Time To Live
*
* @var int
*/
protected $ttl = 8600;
方法
public function __construct( array $options = [] );
构造函数 public function close(): bool;
关闭 public function destroy( mixed $id ): bool;
销毁 public function gc( int $max_lifetime ): int | false;
垃圾回收器 public function open( mixed $path, mixed $name ): bool;
打开 public function read( mixed $id ): string;
读取 public function write( mixed $id, mixed $data ): bool;
写入 protected function getPrefixedName( mixed $name ): string;
获取前缀名称的帮助方法 Session\Adapter\Redis
GitHub上的源码
-
命名空间
-
使用
Phalcon\Storage\AdapterFactory
-
继承
AbstractAdapter
-
实现
Phalcon\Session\Adapter\Redis
方法
public function __construct( AdapterFactory $factory, array $options = [] );
构造函数 Session\Adapter\Stream
GitHub上的源码
-
命名空间
-
使用
Phalcon\Session\Exception
-
继承
Noop
-
实现
Phalcon\Session\Adapter\Stream
这是基于文件的适配器。它将会话存储在基于文件的系统中
<?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
属性
/**
* @var string
*/
private $path = ;
方法
public function __construct( array $options = [] );
构造函数 public function destroy( mixed $id ): bool;
public function gc( int $max_lifetime ): int | false;
垃圾回收器 public function open( mixed $path, mixed $name ): bool;
忽略savePath并使用本地定义的路径 public function read( mixed $id ): string;
从适配器读取数据 public function write( mixed $id, mixed $data ): bool;
protected function getArrVal( array $collection, mixed $index, mixed $defaultValue = null, string $cast = null ): mixed;
@todo 当我们获得特性时,删除这个 protected function getGlobFiles( string $pattern ): array | false;
获取glob数组或在失败时返回false protected function phpFileExists( string $filename );
protected function phpFileGetContents( string $filename );
protected function phpFilePutContents( string $filename, mixed $data, int $flags = int, mixed $context = null );
protected function phpFopen( string $filename, string $mode );
protected function phpIniGet( string $varname ): string;
获取配置选项的值 protected function phpIsWritable( string $filename ): bool;
判断文件名是否可写 Session\Bag
GitHub上的源码
-
命名空间
-
使用
Phalcon\Di\Di
Phalcon\Di\DiInterface
Phalcon\Di\InjectionAwareInterface
Phalcon\Session\ManagerInterface
Phalcon\Support\Collection
-
继承
Collection
-
实现
BagInterface
InjectionAwareInterface
Phalcon\Session\Bag
该组件有助于将会话数据分离到“命名空间”中。通过这种方式,您可以在应用程序中轻松创建会话变量的组
$user = new \Phalcon\Session\Bag("user");
$user->name = "Kimbra Johnson";
$user->age = 22;
@property DiInterface|null $container @property string $name @property ManagerInterface $session;
属性
/**
* @var DiInterface|null
*/
private $container;
/**
* Session Bag name
*
* @var string
*/
private $name;
/**
* @var ManagerInterface
*/
private $session;
方法
public function __construct( ManagerInterface $session, string $name );
public function clear(): void;
销毁会话包 public function getDI(): DiInterface;
返回DependencyInjector容器 public function init( array $data = [] ): void;
初始化内部数组 public function remove( string $element ): void;
从内部包中移除一个属性 public function set( string $element, mixed $value ): void;
在会话包中设置一个值 public function setDI( DiInterface $container ): void;
设置DependencyInjector容器 Session\BagInterface
GitHub上的源码
Phalcon\Session\BagInterface
Phalcon\Session\Bag接口
方法
public function __get( string $element ): mixed;
public function __isset( string $element ): bool;
public function __set( string $element, mixed $value ): void;
public function __unset( string $element ): void;
public function clear(): void;
public function get( string $element, mixed $defaultValue = null, string $cast = null ): mixed;
public function has( string $element ): bool;
public function init( array $data = [] ): void;
public function remove( string $element ): void;
public function set( string $element, mixed $value ): void;
Session\Exception
GitHub上的源码
Phalcon\Session\Exception
在Phalcon\Session中抛出的异常将使用此类
Session\Manager
GitHub上的源码
-
命名空间
-
使用
InvalidArgumentException
Phalcon\Di\AbstractInjectionAware
Phalcon\Di\DiInterface
Phalcon\Support\Helper\Arr\Get
RuntimeException
SessionHandlerInterface
-
继承
AbstractInjectionAware
-
实现
@property SessionHandlerInterface|null $adapter @property string $name @property array $options @property string $uniqueId
属性
/**
* @var SessionHandlerInterface|null
*/
private $adapter;
/**
* @var string
*/
private $name = ;
/**
* @var array
*/
private $options;
/**
* @var string
*/
private $uniqueId = ;
方法
public function __construct( array $options = [] );
Manager构造函数。 public function __get( string $key ): mixed;
别名:从应用程序上下文中获取会话变量 public function __isset( string $key ): bool;
别名:检查是否在应用程序上下文中设置了会话变量 public function __set( string $key, mixed $value ): void;
别名:在应用程序上下文中设置会话变量 public function __unset( string $key ): void;
别名:从应用程序上下文中移除会话变量 public function destroy(): void;
销毁/结束会话 public function exists(): bool;
检查会话是否已启动 public function get( string $key, mixed $defaultValue = null, bool $remove = bool ): mixed;
从应用程序上下文中获取会话变量 public function getAdapter(): SessionHandlerInterface;
返回存储的会话适配器 public function getId(): string;
返回会话id public function getName(): string;
返回会话名称 public function getOptions(): array;
获取内部选项 public function has( string $key ): bool;
检查是否在应用程序上下文中设置了会话变量 public function regenerateId( bool $deleteOldSession = bool ): ManagerInterface;
使用适配器重新生成会话id。 public function remove( string $key ): void;
从应用程序上下文中移除会话变量 public function set( string $key, mixed $value ): void;
在应用程序上下文中设置会话变量 public function setAdapter( SessionHandlerInterface $adapter ): ManagerInterface;
为会话设置适配器 public function setId( string $sessionId ): ManagerInterface;
设置会话Id public function setName( string $name ): ManagerInterface;
设置会话名称。如果会话已启动,则抛出异常,并且不允许使用不当名称 public function setOptions( array $options ): void;
设置会话的选项 public function start(): bool;
启动会话(如果标题已经发送,则不会启动会话) public function status(): int;
返回当前会话的状态。 protected function phpHeadersSent(): bool;
检查标题是否已发送或发送位置 Session\ManagerInterface
GitHub上的源码
-
命名空间
-
使用
InvalidArgumentException
RuntimeException
SessionHandlerInterface
-
继承
-
实现
Phalcon\Session
Phalcon\Session\Manager接口
常量
const SESSION_ACTIVE = 2;
const SESSION_DISABLED = 0;
const SESSION_NONE = 1;
方法
public function __get( string $key ): mixed;
别名:从应用程序上下文中获取会话变量 public function __isset( string $key ): bool;
别名:检查是否在应用程序上下文中设置了会话变量 public function __set( string $key, mixed $value ): void;
别名:在应用程序上下文中设置会话变量 public function __unset( string $key ): void;
别名:从应用程序上下文中移除会话变量 public function destroy(): void;
销毁/结束会话 public function exists(): bool;
检查会话是否已启动 public function get( string $key, mixed $defaultValue = null, bool $remove = bool ): mixed;
从应用程序上下文中获取会话变量 public function getAdapter(): SessionHandlerInterface;
返回存储的会话适配器 public function getId(): string;
返回会话id public function getName(): string;
返回会话名称 public function getOptions(): array;
获取内部选项 public function has( string $key ): bool;
检查是否在应用程序上下文中设置了会话变量 public function regenerateId( bool $deleteOldSession = bool ): ManagerInterface;
使用适配器重新生成会话id。 public function remove( string $key ): void;
从应用程序上下文中移除会话变量 public function set( string $key, mixed $value ): void;
在应用程序上下文中设置会话变量 public function setAdapter( SessionHandlerInterface $adapter ): ManagerInterface;
为会话设置适配器 public function setId( string $sessionId ): ManagerInterface;
设置会话Id public function setName( string $name ): ManagerInterface;
设置会话名称。如果会话已启动,则抛出异常,并且不允许使用不当名称 @throws InvalidArgumentException
public function setOptions( array $options ): void;
设置会话的选项 public function start(): bool;
启动会话(如果标题已经发送,则不会启动会话) public function status(): int;
返回当前会话的状态。