diff options
author | Florian Pritz <bluewind@xinu.at> | 2013-09-04 14:59:34 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-09-04 14:59:34 +0200 |
commit | cce1fe9bfea359cebae585eaaa944650bace4966 (patch) | |
tree | dedd328007271e40545fa0cfe493cfd63763be4a /application/libraries/MY_Session.php | |
parent | 54d5d869ad2c525dd276f28a8409658a106d9e3f (diff) |
Only store session information for stateful clients
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/libraries/MY_Session.php')
-rw-r--r-- | application/libraries/MY_Session.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/application/libraries/MY_Session.php b/application/libraries/MY_Session.php new file mode 100644 index 000000000..0443bca31 --- /dev/null +++ b/application/libraries/MY_Session.php @@ -0,0 +1,38 @@ +<?php +/* + * Copyright 2013 Florian "Bluewind" Pritz <bluewind@server-speed.net> + * + * Licensed under AGPLv3 + * (see COPYING for full license text) + * + */ + +class MY_Session extends CI_Session { + private $memory_only = false; + + public function __construct() { + $CI =& get_instance(); + $CI->load->helper("filebin"); + + /* Clients using API keys do not need a persistent session since API keys + * should be sent with each request. This reduces database queries and + * prevents us from sending useless cookies. + */ + if (!stateful_client()) { + $this->memory_only = true; + $CI->config->set_item("sess_use_database", false); + } + + parent::__construct(); + } + + public function _set_cookie($cookie_data = NULL) + { + if ($this->memory_only) { + return; + } + + parent::_set_cookie($cookie_data); + + } +} |