Skip to content

Instantly share code, notes, and snippets.

@kevincupp
Created January 6, 2012 18:59
Show Gist options
  • Select an option

  • Save kevincupp/1571916 to your computer and use it in GitHub Desktop.

Select an option

Save kevincupp/1571916 to your computer and use it in GitHub Desktop.
EE Anonymous User Fix
diff --git a/system/expressionengine/libraries/Auth.php b/system/expressionengine/libraries/Auth.php
index 82c0bfb..992bc6c 100644
--- a/system/expressionengine/libraries/Auth.php
+++ b/system/expressionengine/libraries/Auth.php
@@ -572,6 +572,7 @@ class Auth_result {
private $member;
private $session_id;
private $remember_me = 0;
+ private $anon = FALSE;
private $EE;
/**
@@ -702,6 +703,19 @@ class Auth_result {
{
$this->remember_me = $expire;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Anon setter
+ *
+ * @access public
+ */
+ function anon($anon)
+ {
+ $this->anon = $anon;
+ }
+
// --------------------------------------------------------------------
@@ -722,9 +736,18 @@ class Auth_result {
{
$expire = $this->remember_me;
- $this->EE->functions->set_cookie(
- $this->EE->session->c_anon, 1, $expire
- );
+ if ($this->anon)
+ {
+ $this->EE->functions->set_cookie(
+ $this->EE->session->c_anon, 1, $expire
+ );
+ }
+ else
+ {
+ // Unset the anon cookie
+ $this->EE->functions->set_cookie($this->EE->session->c_anon);
+ }
+
$this->EE->functions->set_cookie(
$this->EE->session->c_expire, time()+$expire, $expire
);
diff --git a/system/expressionengine/modules/member/mod.member_auth.php b/system/expressionengine/modules/member/mod.member_auth.php
index a3c277e..ac9bfbf 100644
--- a/system/expressionengine/modules/member/mod.member_auth.php
+++ b/system/expressionengine/modules/member/mod.member_auth.php
@@ -260,6 +260,10 @@ class Member_auth extends Member {
$sess->remember_me(60*60*24*365);
}
+ $anon = ($this->EE->input->post('anon') == 1) ? FALSE : TRUE;
+
+ $sess->anon($anon);
+
$sess->start_session();
$this->_update_online_user_stats();
@@ -485,7 +489,7 @@ class Member_auth extends Member {
// Update stats
$cutoff = $this->EE->localize->now - (15 * 60);
- $anon = ($this->EE->input->post('anon') == 1) ? 'n' : 'y';
+ $anon = ($this->EE->input->post('anon') == 1) ? '' : 'y';
$in_forum = ($this->EE->input->get_post('FROM') == 'forum') ? 'y' : 'n';
@chadhutchins
Copy link

Will do, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment