Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: eric1234 on November 07, 2013, 12:57:26 PM

Title: Forever login?
Post by: eric1234 on November 07, 2013, 12:57:26 PM
My users complained that they logged in but after sometime browsing the forum or leave it idle, it auto log out again. How to make every users forever login like in this site?
Title: Re: Forever login?
Post by: margarett on November 07, 2013, 01:02:02 PM
If nothing is wrong, you should get logged in "forever" if they check the correct option when they login...

Can you reproduce this yourself or are they just telling you?

You can also change the default cookie duration in your ACP to a huge number so that, if they don't check the option, they still get a big number so it would be like "forever"
Title: Re: Forever login?
Post by: eric1234 on November 07, 2013, 01:25:00 PM
Quote from: margarett on November 07, 2013, 01:02:02 PM
If nothing is wrong, you should get logged in "forever" if they check the correct option when they login...

Can you reproduce this yourself or are they just telling you?

You can also change the default cookie duration in your ACP to a huge number so that, if they don't check the option, they still get a big number so it would be like "forever"
I also cant reproduce this myself :(

Default cookies? you mean Minutes to stay logged in?
Title: Re: Forever login?
Post by: margarett on November 07, 2013, 01:28:00 PM
index.php?action=admin;area=serversettings;sa=cookie;

"Default login cookies length (in minutes)"

;)
Title: Re: Forever login?
Post by: Sir Osis of Liver on November 07, 2013, 01:33:27 PM

You can edit the login templates to remove the session length option and hardcode all logins to forever.

Title: Re: Forever login?
Post by: eric1234 on November 07, 2013, 01:38:29 PM
Quote from: Krash. on November 07, 2013, 01:33:27 PM

You can edit the login templates to remove the session length option and hardcode all logins to forever.


Mind to elaborate on how to do that?

Quote from: margarett on November 07, 2013, 01:28:00 PM
index.php?action=admin;area=serversettings;sa=cookie;

"Default login cookies length (in minutes)"

;)
Checking it now
Title: Re: Forever login?
Post by: Sir Osis of Liver on November 07, 2013, 03:07:10 PM

You remove the 'Forever' dropdown in the header login in index.template.php, and add -



<input type="hidden" name="cookielength" value="-1" />



In Login.template.php, remove 'Minutes to stay logged in:' and 'Always stay logged in:', and add the same line to the code.  You have to do this in 3 or 4 places.  Search 'cookielegth' to find them all.

Title: Re: Forever login?
Post by: eric1234 on November 08, 2013, 12:00:29 PM
Quote from: Krash. on November 07, 2013, 03:07:10 PM

You remove the 'Forever' dropdown in the header login in index.template.php, and add -



<input type="hidden" name="cookielength" value="-1" />



In Login.template.php, remove 'Minutes to stay logged in:' and 'Always stay logged in:', and add the same line to the code.  You have to do this in 3 or 4 places.  Search 'cookielegth' to find them all.
How to remove??

remove the 'Forever' dropdown in the header login in index.template.php
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>


remove 'Minutes to stay logged in:' and 'Always stay logged in:'
<dt>', $txt['mins_logged_in'], ':</dt>
<dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled="disabled"' : '', ' class="input_text" /></dd>
<dt>', $txt['always_logged_in'], ':</dt>
<dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked="checked"' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;" /></dd>';


by the way, is it by changing the code , everyone in my forum including myself will be forever logged in? But why the current system even when we ticked always stayed logged in , still eventually after some time will be auto log out?
Title: Re: Forever login?
Post by: Kindred on November 08, 2013, 09:19:02 PM
no. If you have the forever chosen, you will NOT be logged out "after some time"

unless you delete your browser cookies
Title: Re: Forever login?
Post by: eric1234 on November 09, 2013, 01:00:35 AM
Quote from: Kindred on November 08, 2013, 09:19:02 PM
no. If you have the forever chosen, you will NOT be logged out "after some time"

unless you delete your browser cookies
"after some time" is how long?
Title: Re: Forever login?
Post by: oridyne on November 09, 2013, 04:31:29 AM
Quote from: Kindred on November 08, 2013, 09:19:02 PM
no. If you have the forever chosen, you will NOT be logged out "after some time"

unless you delete your browser cookies


I have noticed recently that both on my phone and PC I am repeatedly having to re-logon to my forum despite having "Forever" checked and no changes to settings on either device affecting cookies.


Whether this is as a consequence of the recent update I am not sure but it has been working fine. I use Chrome on my PC and Dolphin on my Android smartphone if that helps.
Title: Re: Forever login?
Post by: Kindred on November 09, 2013, 09:16:33 AM
eric1234,

I don't think you are actually paying attention.  I QUOTED your statement of "after some time" (which is why it was in quotes.
After some time is NEVER if you have a standard, unmodified installation and don't delete cookies.
period.
What you are experiencing suggests that either you have messed around with the code, in which case, all bets are off and it could be doing anything, since we have no idea how you have screwed up the code or that you are deleting your cookies on your local browser - which will, indeed end your session.

oridyne,
see above.
Title: Re: Forever login?
Post by: Sir Osis of Liver on November 09, 2013, 02:00:33 PM

Quote from: eric1234 on November 08, 2013, 12:00:29 PM
How to remove??

Just comment out or delete those lines.

Quote
by the way, is it by changing the code , everyone in my forum including myself will be forever logged in? But why the current system even when we ticked always stayed logged in , still eventually after some time will be auto log out?

By setting cookielength = -1, users stay logged in until they log out, or cookie is deleted.

Title: Re: Forever login?
Post by: oridyne on November 09, 2013, 03:51:39 PM
Quote from: Kindred on November 09, 2013, 09:16:33 AM
eric1234,

I don't think you are actually paying attention.  I QUOTED your statement of "after some time" (which is why it was in quotes.
After some time is NEVER if you have a standard, unmodified installation and don't delete cookies.
period.
What you are experiencing suggests that either you have messed around with the code, in which case, all bets are off and it could be doing anything, since we have no idea how you have screwed up the code or that you are deleting your cookies on your local browser - which will, indeed end your session.

oridyne,
see above.


Firstly my bad, I replied to this having seen the Forever login title, missing that it was for SMF 2.0 where I am running 1.1.19.


Whilst I have multiple mods, and have had to make some minor changes in the past to mod code to fix issues with my site, none of this has been done recently and certainly not since the recent update. The forever login has been working fine, though recently, not sure if it coincided with the security update I'm afraid, I have noticed this issue happening on my devices connecting to the forum.


I have made no browser config changes, no code changes but yet I see this happening despite your insistence. I merely posted to confirm that someone else was seeing the same issue as the OP. Not a problem for me to keep logging in, just thought I would try and help as there may be an issue.


Just because something should work does not mean there is not a problem, especially with such a complicated bit of code as SMF, it is always far to easy to miss something.
That said, I could not code anything as complicated as this and concede to your superior knowledge of your own product for which I thank the entire dev team for their continued efforts it is much appreciated.


I will just resign myself to logging in more frequently and bow gracefully out of this conversation.



Title: Re: Forever login?
Post by: Kindred on November 09, 2013, 04:20:43 PM
oridyne,

the cookie/login for SMF 1.1.x has been working for everyone for the past 8 years....     so, if you have an issue, it would seem to be very specific to your site.
Not saying there is not an issue, just saying that the issue is NOT in the SMF core code.