Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CSession.php « core « classes « include « php « frontends - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f6ef5f63b64f55275cfe3d3ad59aca0583c9942d (plain)
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
<?php

class CSession implements ArrayAccess {

	/**
	 * Initialize session.
	 * Set cookie path to path to current URI without file.
	 *
	 * @throw Exception if cannot start session
	 */
	public function __construct() {
		$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
		// remove file name from path
		$path = substr($path, 0, strrpos($path, '/') + 1);

		session_set_cookie_params(0, $path, null, HTTPS);

		if (!session_start()) {
			throw new Exception('Cannot start session.');
		}
	}

	public function offsetSet($offset, $value) {
		$_SESSION[$offset] = $value;
	}

	public function offsetExists($offset) {
		return isset($_SESSION[$offset]);
	}

	public function offsetUnset($offset) {
		unset($_SESSION[$offset]);
	}

	public function offsetGet($offset) {
		return isset($_SESSION[$offset]) ? $_SESSION[$offset] : null;
	}
}