Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 1 | <?php |
| 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Andrey Andreev | bf6b11d | 2015-01-12 17:27:12 +0200 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 6 | * |
Andrey Andreev | 46f2f26 | 2014-11-11 14:37:51 +0200 | [diff] [blame] | 7 | * This content is released under the MIT License (MIT) |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 8 | * |
Andrey Andreev | bf6b11d | 2015-01-12 17:27:12 +0200 | [diff] [blame] | 9 | * Copyright (c) 2014 - 2015, British Columbia Institute of Technology |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 10 | * |
Andrey Andreev | 46f2f26 | 2014-11-11 14:37:51 +0200 | [diff] [blame] | 11 | * 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 Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 17 | * |
Andrey Andreev | 46f2f26 | 2014-11-11 14:37:51 +0200 | [diff] [blame] | 18 | * 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 Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 31 | * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) |
Andrey Andreev | bf6b11d | 2015-01-12 17:27:12 +0200 | [diff] [blame] | 32 | * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) |
Andrey Andreev | 46f2f26 | 2014-11-11 14:37:51 +0200 | [diff] [blame] | 33 | * @license http://opensource.org/licenses/MIT MIT License |
| 34 | * @link http://codeigniter.com |
| 35 | * @since Version 3.0.0 |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 36 | * @filesource |
| 37 | */ |
| 38 | defined('BASEPATH') OR exit('No direct script access allowed'); |
| 39 | |
| 40 | /** |
| 41 | * CodeIgniter Session Driver Class |
| 42 | * |
Andrey Andreev | 46f2f26 | 2014-11-11 14:37:51 +0200 | [diff] [blame] | 43 | * @package CodeIgniter |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 44 | * @subpackage Libraries |
| 45 | * @category Sessions |
Andrey Andreev | 46f2f26 | 2014-11-11 14:37:51 +0200 | [diff] [blame] | 46 | * @author Andrey Andreev |
| 47 | * @link http://codeigniter.com/user_guide/libraries/sessions.html |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 48 | */ |
| 49 | abstract class CI_Session_driver implements SessionHandlerInterface { |
| 50 | |
Andrey Andreev | dfb39be | 2014-10-06 01:50:14 +0300 | [diff] [blame] | 51 | protected $_config; |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 52 | |
| 53 | /** |
Andrey Andreev | 93d9fa7 | 2014-08-27 22:14:36 +0300 | [diff] [blame] | 54 | * Data fingerprint |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 55 | * |
| 56 | * @var bool |
| 57 | */ |
| 58 | protected $_fingerprint; |
| 59 | |
Andrey Andreev | 93d9fa7 | 2014-08-27 22:14:36 +0300 | [diff] [blame] | 60 | /** |
| 61 | * Lock placeholder |
| 62 | * |
| 63 | * @var mixed |
| 64 | */ |
| 65 | protected $_lock = FALSE; |
| 66 | |
Andrey Andreev | 7474a67 | 2014-10-31 23:35:32 +0200 | [diff] [blame] | 67 | /** |
| 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 Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 77 | // ------------------------------------------------------------------------ |
| 78 | |
| 79 | /** |
| 80 | * Class constructor |
| 81 | * |
| 82 | * @param array $params Configuration parameters |
| 83 | * @return void |
| 84 | */ |
Andrey Andreev | dfb39be | 2014-10-06 01:50:14 +0300 | [diff] [blame] | 85 | public function __construct(&$params) |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 86 | { |
Andrey Andreev | dfb39be | 2014-10-06 01:50:14 +0300 | [diff] [blame] | 87 | $this->_config =& $params; |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | // ------------------------------------------------------------------------ |
| 91 | |
| 92 | protected function _cookie_destroy() |
| 93 | { |
| 94 | return setcookie( |
Andrey Andreev | dfb39be | 2014-10-06 01:50:14 +0300 | [diff] [blame] | 95 | $this->_config['cookie_name'], |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 96 | NULL, |
| 97 | 1, |
Andrey Andreev | dfb39be | 2014-10-06 01:50:14 +0300 | [diff] [blame] | 98 | $this->_config['cookie_path'], |
| 99 | $this->_config['cookie_domain'], |
| 100 | $this->_config['cookie_secure'], |
| 101 | TRUE |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 102 | ); |
| 103 | } |
| 104 | |
Andrey Andreev | 93d9fa7 | 2014-08-27 22:14:36 +0300 | [diff] [blame] | 105 | // ------------------------------------------------------------------------ |
| 106 | |
| 107 | /** |
| 108 | * Get lock |
| 109 | * |
Andrey Andreev | 19c2524 | 2015-01-14 22:13:36 +0200 | [diff] [blame^] | 110 | * A dummy method allowing drivers with no locking functionality |
| 111 | * (databases other than PostgreSQL and MySQL) to act as if they |
| 112 | * do acquire a lock. |
Andrey Andreev | 93d9fa7 | 2014-08-27 22:14:36 +0300 | [diff] [blame] | 113 | * |
| 114 | * @param string $session_id |
| 115 | * @return bool |
| 116 | */ |
| 117 | protected function _get_lock($session_id) |
| 118 | { |
Andrey Andreev | 19c2524 | 2015-01-14 22:13:36 +0200 | [diff] [blame^] | 119 | $this->_lock = TRUE; |
Andrey Andreev | 93d9fa7 | 2014-08-27 22:14:36 +0300 | [diff] [blame] | 120 | return TRUE; |
| 121 | } |
| 122 | |
| 123 | // ------------------------------------------------------------------------ |
| 124 | |
| 125 | /** |
| 126 | * Release lock |
| 127 | * |
| 128 | * @return bool |
| 129 | */ |
| 130 | protected function _release_lock() |
| 131 | { |
Andrey Andreev | 19c2524 | 2015-01-14 22:13:36 +0200 | [diff] [blame^] | 132 | if ($this->_lock) |
Andrey Andreev | 93d9fa7 | 2014-08-27 22:14:36 +0300 | [diff] [blame] | 133 | { |
Andrey Andreev | 93d9fa7 | 2014-08-27 22:14:36 +0300 | [diff] [blame] | 134 | $this->_lock = FALSE; |
| 135 | } |
| 136 | |
| 137 | return TRUE; |
| 138 | } |
| 139 | |
Andrey Andreev | 47a47fb | 2014-05-31 16:08:30 +0300 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /* End of file Session_driver.php */ |
| 143 | /* Location: ./system/libraries/Session/Session_driver.php */ |