blob: 8edd319994658c85cf07489470443eec306ecc69 [file] [log] [blame]
Andrey Andreev47a47fb2014-05-31 16:08:30 +03001<?php
2/**
3 * CodeIgniter
4 *
Ivan Tcholakov90da83c2015-01-19 17:23:08 +02005 * An open source application development framework for PHP
Andrey Andreev47a47fb2014-05-31 16:08:30 +03006 *
Andrey Andreev46f2f262014-11-11 14:37:51 +02007 * This content is released under the MIT License (MIT)
Andrey Andreev47a47fb2014-05-31 16:08:30 +03008 *
Andrey Andreevbf6b11d2015-01-12 17:27:12 +02009 * Copyright (c) 2014 - 2015, British Columbia Institute of Technology
Andrey Andreev47a47fb2014-05-31 16:08:30 +030010 *
Andrey Andreev46f2f262014-11-11 14:37:51 +020011 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
Andrey Andreev47a47fb2014-05-31 16:08:30 +030017 *
Andrey Andreev46f2f262014-11-11 14:37:51 +020018 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * THE SOFTWARE.
28 *
29 * @package CodeIgniter
30 * @author EllisLab Dev Team
Andrey Andreev47a47fb2014-05-31 16:08:30 +030031 * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
Andrey Andreevbf6b11d2015-01-12 17:27:12 +020032 * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
Andrey Andreev46f2f262014-11-11 14:37:51 +020033 * @license http://opensource.org/licenses/MIT MIT License
34 * @link http://codeigniter.com
35 * @since Version 3.0.0
Andrey Andreev47a47fb2014-05-31 16:08:30 +030036 * @filesource
37 */
38defined('BASEPATH') OR exit('No direct script access allowed');
39
40/**
41 * CodeIgniter Session Driver Class
42 *
Andrey Andreev46f2f262014-11-11 14:37:51 +020043 * @package CodeIgniter
Andrey Andreev47a47fb2014-05-31 16:08:30 +030044 * @subpackage Libraries
45 * @category Sessions
Andrey Andreev46f2f262014-11-11 14:37:51 +020046 * @author Andrey Andreev
47 * @link http://codeigniter.com/user_guide/libraries/sessions.html
Andrey Andreev47a47fb2014-05-31 16:08:30 +030048 */
49abstract class CI_Session_driver implements SessionHandlerInterface {
50
Andrey Andreevdfb39be2014-10-06 01:50:14 +030051 protected $_config;
Andrey Andreev47a47fb2014-05-31 16:08:30 +030052
53 /**
Andrey Andreev93d9fa72014-08-27 22:14:36 +030054 * Data fingerprint
Andrey Andreev47a47fb2014-05-31 16:08:30 +030055 *
56 * @var bool
57 */
58 protected $_fingerprint;
59
Andrey Andreev93d9fa72014-08-27 22:14:36 +030060 /**
61 * Lock placeholder
62 *
63 * @var mixed
64 */
65 protected $_lock = FALSE;
66
Andrey Andreev7474a672014-10-31 23:35:32 +020067 /**
68 * Read session ID
69 *
70 * Used to detect session_regenerate_id() calls because PHP only calls
71 * write() after regenerating the ID.
72 *
73 * @var string
74 */
75 protected $_session_id;
76
Andrey Andreev47a47fb2014-05-31 16:08:30 +030077 // ------------------------------------------------------------------------
78
79 /**
80 * Class constructor
81 *
82 * @param array $params Configuration parameters
83 * @return void
84 */
Andrey Andreevdfb39be2014-10-06 01:50:14 +030085 public function __construct(&$params)
Andrey Andreev47a47fb2014-05-31 16:08:30 +030086 {
Andrey Andreevdfb39be2014-10-06 01:50:14 +030087 $this->_config =& $params;
Andrey Andreev47a47fb2014-05-31 16:08:30 +030088 }
89
90 // ------------------------------------------------------------------------
91
Andrey Andreev10411fc2015-01-19 13:54:53 +020092 /**
93 * Cookie destroy
94 *
95 * Internal method to force removal of a cookie by the client
96 * when session_destroy() is called.
97 *
98 * @return bool
99 */
Andrey Andreev47a47fb2014-05-31 16:08:30 +0300100 protected function _cookie_destroy()
101 {
102 return setcookie(
Andrey Andreevdfb39be2014-10-06 01:50:14 +0300103 $this->_config['cookie_name'],
Andrey Andreev47a47fb2014-05-31 16:08:30 +0300104 NULL,
105 1,
Andrey Andreevdfb39be2014-10-06 01:50:14 +0300106 $this->_config['cookie_path'],
107 $this->_config['cookie_domain'],
108 $this->_config['cookie_secure'],
109 TRUE
Andrey Andreev47a47fb2014-05-31 16:08:30 +0300110 );
111 }
112
Andrey Andreev93d9fa72014-08-27 22:14:36 +0300113 // ------------------------------------------------------------------------
114
115 /**
116 * Get lock
117 *
Andrey Andreev19c25242015-01-14 22:13:36 +0200118 * A dummy method allowing drivers with no locking functionality
119 * (databases other than PostgreSQL and MySQL) to act as if they
120 * do acquire a lock.
Andrey Andreev93d9fa72014-08-27 22:14:36 +0300121 *
122 * @param string $session_id
123 * @return bool
124 */
125 protected function _get_lock($session_id)
126 {
Andrey Andreev19c25242015-01-14 22:13:36 +0200127 $this->_lock = TRUE;
Andrey Andreev93d9fa72014-08-27 22:14:36 +0300128 return TRUE;
129 }
130
131 // ------------------------------------------------------------------------
132
133 /**
134 * Release lock
135 *
136 * @return bool
137 */
138 protected function _release_lock()
139 {
Andrey Andreev19c25242015-01-14 22:13:36 +0200140 if ($this->_lock)
Andrey Andreev93d9fa72014-08-27 22:14:36 +0300141 {
Andrey Andreev93d9fa72014-08-27 22:14:36 +0300142 $this->_lock = FALSE;
143 }
144
145 return TRUE;
146 }
147
Andrey Andreev47a47fb2014-05-31 16:08:30 +0300148}
149
150/* End of file Session_driver.php */
151/* Location: ./system/libraries/Session/Session_driver.php */