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

Commit

Permalink
corrected domain prefix, added cookie removal logic, #290
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnR committed Mar 25, 2014
1 parent f045832 commit 8ca1ca9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions Code_Igniter/application/libraries/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ public function __construct()
public function setMeta($username = NULL) {

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

if (!$this->getCookie('deviceid')) {
Expand Down Expand Up @@ -55,6 +59,16 @@ private function getCookie($name)
{
return $this->CI->input->cookie($this->cookie_prefix . $name, TRUE);
}
private function removeCookie($name)
{
return $this->CI->input->set_cookie(
array(
'name' => $this->cookie_prefix . $name,
'value' => '',
'expire' => 0
)
);
}

private function generate_deviceid()
{
Expand All @@ -65,7 +79,8 @@ private function generate_deviceid()
private function get_domain()
{
$base_url = base_url();
return substr( $base_url, strpos($base_url, '://') + 3 );
$domain = substr( $base_url, strpos($base_url, '://') + 3 );
return (strrpos($domain, '/') === strlen($domain) - 1) ? substr($domain, 0, -1) : $domain;
}
}

Expand Down
2 changes: 1 addition & 1 deletion public/lib/enketo-core

0 comments on commit 8ca1ca9

Please sign in to comment.