Skip to content
This repository was archived by the owner on Jun 9, 2018. It is now read-only.

Commit 8ca1ca9

Browse files
committed
corrected domain prefix, added cookie removal logic, #290
1 parent f045832 commit 8ca1ca9

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Code_Igniter/application/libraries/Meta.php

+17-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ public function __construct()
2424
public function setMeta($username = NULL) {
2525

2626
log_message('debug', 'setting meta with username:'.$username);
27-
if ($username && !$this->getCookie('uid')) {
27+
if ($username) {
28+
// always re-set this value
2829
$this->setCookie( 'uid', $this->domain.':'.$username);
30+
} else {
31+
// but remove it if no username is stored in current session
32+
$this->removeCookie ('uid');
2933
}
3034

3135
if (!$this->getCookie('deviceid')) {
@@ -55,6 +59,16 @@ private function getCookie($name)
5559
{
5660
return $this->CI->input->cookie($this->cookie_prefix . $name, TRUE);
5761
}
62+
private function removeCookie($name)
63+
{
64+
return $this->CI->input->set_cookie(
65+
array(
66+
'name' => $this->cookie_prefix . $name,
67+
'value' => '',
68+
'expire' => 0
69+
)
70+
);
71+
}
5872

5973
private function generate_deviceid()
6074
{
@@ -65,7 +79,8 @@ private function generate_deviceid()
6579
private function get_domain()
6680
{
6781
$base_url = base_url();
68-
return substr( $base_url, strpos($base_url, '://') + 3 );
82+
$domain = substr( $base_url, strpos($base_url, '://') + 3 );
83+
return (strrpos($domain, '/') === strlen($domain) - 1) ? substr($domain, 0, -1) : $domain;
6984
}
7085
}
7186

public/lib/enketo-core

0 commit comments

Comments
 (0)