File: External.php

package info (click to toggle)
php-horde-sessionhandler 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 396 kB
  • sloc: php: 1,487; xml: 672; sh: 14; makefile: 2
file content (96 lines) | stat: -rw-r--r-- 2,520 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
 * SessionHandler storage implementation for an external save handler defined
 * via configuration parameters.
 *
 * Copyright 2010-2017 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 *
 * @author   Michael Slusarz <slusarz@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package  SessionHandler
 */
class Horde_SessionHandler_Storage_External extends Horde_SessionHandler_Storage
{
    /**
     * Constructor.
     *
     * @param array $params  Required parameters:
     * <pre>
     * close - (callback) See session_set_save_handler().
     * destroy - (callback) See session_set_save_handler().
     * gc - (callback) See session_set_save_handler().
     * open - (callback) See session_set_save_handler().
     * read - (callback) See session_set_save_handler().
     * write - (callback) See session_set_save_handler().
     * </pre>
     *
     * @throws InvalidArgumentException
     */
    public function __construct(array $params = array())
    {
        foreach (array('open', 'close', 'read', 'write', 'destroy', 'gc') as $val) {
            if (!isset($params[$val])) {
                throw new InvalidArgumentException('Missing parameter: ' . $val);
            }
        }

        parent::__construct($params);
    }

    /**
     */
    public function open($save_path = null, $session_name = null)
    {
        return call_user_func($this->_params['open'], $save_path, $session_name);
    }

    /**
     */
    public function close()
    {
        return call_user_func($this->_params['close']);
    }

    /**
     */
    public function read($id)
    {
        return call_user_func($this->_params['read'], $id);
    }

    /**
     */
    public function write($id, $session_data)
    {
        return call_user_func($this->_params['write'], $id, $session_data);
    }

    /**
     */
    public function destroy($id)
    {
        return call_user_func($this->_params['destroy'], $id);
    }

    /**
     */
    public function gc($maxlifetime = 300)
    {
        return call_user_func($this->_params['gc'], $maxlifetime);
    }

    /**
     * Get a list of the valid session identifiers.
     *
     * @throws Horde_SessionHandler_Exception
     */
    public function getSessionIDs()
    {
        throw new Horde_SessionHandler_Exception('Driver does not support listing session IDs.');
    }

}