Created
January 6, 2012 18:59
-
-
Save kevincupp/1571916 to your computer and use it in GitHub Desktop.
EE Anonymous User Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think there's a little more to it, like setting cookies and things. Take a look at this add-on to see if it's useful to you, or look at the PHP they're using to log a user in: http://devot-ee.com/add-ons/logmein