1 | <?php |
||
39 | class CacheSession extends Session |
||
40 | { |
||
41 | /** |
||
42 | * @var Cache|array|string the cache object or the application component ID of the cache object. |
||
43 | * The session data will be stored using this cache object. |
||
44 | * |
||
45 | * After the CacheSession object is created, if you want to change this property, |
||
46 | * you should only assign it with a cache object. |
||
47 | * |
||
48 | * Starting from version 2.0.2, this can also be a configuration array for creating the object. |
||
49 | */ |
||
50 | public $cache = 'cache'; |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Initializes the application component. |
||
55 | */ |
||
56 | 3 | public function init() |
|
61 | |||
62 | /** |
||
63 | * Returns a value indicating whether to use custom session storage. |
||
64 | * This method overrides the parent implementation and always returns true. |
||
65 | * @return bool whether to use custom storage. |
||
66 | */ |
||
67 | 1 | public function getUseCustomStorage() |
|
68 | { |
||
69 | 1 | return true; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * Session read handler. |
||
74 | * @internal Do not call this method directly. |
||
75 | * @param string $id session ID |
||
76 | * @return string the session data |
||
77 | */ |
||
78 | 8 | public function readSession($id) |
|
84 | |||
85 | /** |
||
86 | * Session write handler. |
||
87 | * @internal Do not call this method directly. |
||
88 | * @param string $id session ID |
||
89 | * @param string $data session data |
||
90 | * @return bool whether session write is successful |
||
91 | */ |
||
92 | 8 | public function writeSession($id, $data) |
|
96 | |||
97 | /** |
||
98 | * Session destroy handler. |
||
99 | * @internal Do not call this method directly. |
||
100 | * @param string $id session ID |
||
101 | * @return bool whether session is destroyed successfully |
||
102 | */ |
||
103 | 3 | public function destroySession($id) |
|
112 | |||
113 | /** |
||
114 | * Generates a unique key used for storing session data in cache. |
||
115 | * @param string $id session variable name |
||
116 | * @return mixed a safe cache key associated with the session variable name |
||
117 | */ |
||
118 | 9 | protected function calculateKey($id) |
|
122 | } |
||
123 |