AloFramework documentation
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Alo
    • Cache
    • CLI
    • Controller
    • Db
    • Exception
    • FileSystem
    • Session
    • Statics
    • Test
    • Validators
    • Windows
  • Controller
  • None
  • PHP

Classes

  • AbstractCacheSession
  • AbstractSession
  • MemcachedSession
  • RedisSession
  • SQLSession
 1 <?php
 2 
 3    namespace Alo\Session;
 4 
 5    use Alo\Cache\AbstractCache;
 6 
 7    if(!defined('GEN_START')) {
 8       http_response_code(404);
 9       die();
10    }
11    \Alo::loadConfig('session');
12 
13    /**
14     * The session interface
15     *
16     * @author  Art <a.molcanovas@gmail.com>
17     * @package Session
18     */
19    abstract class AbstractCacheSession extends AbstractSession {
20 
21       /**
22        * Reference to cache wrapper instance
23        *
24        * @var AbstractCache
25        */
26       protected $client;
27 
28       /**
29        * Cache prefix to use
30        *
31        * @var string
32        */
33       protected $prefix;
34 
35       /**
36        * Fetches session data
37        *
38        * @author Art <a.molcanovas@gmail.com>
39        * @return MemcachedSession
40        */
41       protected function fetch() {
42          $data = $this->client->get($this->prefix . $this->id);
43 
44          if($data) {
45             $this->data = $data;
46          }
47 
48          \Log::debug('Fetched session data');
49 
50          return $this;
51       }
52 
53       /**
54        * Terminates the session
55        *
56        * @author Art <a.molcanovas@gmail.com>
57        * @return MemcachedSession
58        */
59       function terminate() {
60          $this->client->delete($this->prefix . $this->id);
61 
62          return parent::terminate();
63       }
64 
65       /**
66        * Saves session data
67        *
68        * @author Art <a.molcanovas@gmail.com>
69        * @return MemcachedSession
70        */
71       protected function write() {
72          $this->client->set($this->prefix . $this->id, $this->data, ALO_SESSION_TIMEOUT);
73          \Log::debug('Saved session data');
74 
75          return $this;
76       }
77    }
AloFramework documentation API documentation generated by ApiGen 2.8.0