We have a members only gallery. My users (god bless'em) don't want to have to type their details in every time they log in. They want a "Remember me" button, so they are re-logged in automatically.
Has anyone implemented something like this? If not, any suggestions on what needs to be done?
a T d H v A a N n K c S e
Posts: 8194
The problem is PHP sessions. Sessions don't last more than one browser session by default (you may be able to change this with PHP directives, but I've never tried). Not using PHP sessions would undermine almost every part of Gallery, so I don't know how you'd do this :sad:
Posts: 974
In init.php, replace this with this (but this doesn't give users the option of choosing whether or not to remember them)
Old:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
/* Start a new session, or resume our current one */
session_start();
</TD></TR></TABLE><!-- BBCode End -->
New:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
/* Start a new session, or resume our current one */
$session_expire = 86400;
$cookie_expire = time()+$session_expire;
ini_set("session.cookie_lifetime",$session_expire);
session_start();
</TD></TR></TABLE><!-- BBCode End -->
Based on:
http://www.php.net/manual/en/function.session-set-cookie-params.php
http://www.php.net/manual/sv/ref.session.php
Posts: 3473
Thanks guys, I had a play, and it looks like right solution.
However, it looks like we'll be moving to XOOP (or similar) so that will presumably solve the problem without me doing any work, so this is on hold for the moment.
Posts: 42
Do you think that if there is a check box option when the user logs in that would then choose between which of the 2 functions to use would work. I don't know much about PHP and even less about php sessions. I think that if there was the option to stay logged in or not would be really good for the gallery users that have restricted commenting to only logged in users.
thanks
linton