I would like a "Remember Me" feature for Logintoboggan -- i.e., a cookie that stores the users' login details.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | logintoboggan.module.txt | 46.91 KB | senthiln |
| #7 | rememberme_0.patch | 18.8 KB | joshk |
| #6 | rememberme.patch | 18.73 KB | joshk |
Comments
Comment #1
Ogredude commentedNormally, I can't stand "me too" posts... But this seems like a good place for one.
Me too!
Comment #2
hunmonk commentedi have no interest in coding this, but if somebody wants to submit a patch for the feature, then i'll review it for possible inclusion. i think it would be best if it was an optional feature. also, i won't add new features to the 4.6 version, so moving this to a 4.7 request.
Comment #3
FiReaNGeL commentedI'd be interested in this also. It's a shame that currently there's no way to have a 'remember me' login in Drupal... really, every system and website out there use this scheme. It must be for a (good) reason! You can't trust users signing out on public terminals :(
Comment #4
joshk commentedJust a bump, because this is a good idea, but also to explain why this is hard.
The way the login system works is off PHP's built-in session system. This is good. It's secure and robust. However, the lifetime of this session cookie is set by php (at compile-time and through php.ini and .htaccess files), and modified a bit in session.inc.
One way to do this would be for logintoboggan to have it's own "remembered sessions" table and it's own cookie. Another way would be to have LT implement some kind of code to change the session lifetime site-wide.
One easy thing, which I think I'm going to code today would be a separate session table that just remembers usernames. This would let the login name field be pre-filled when people return, but still prompt them for the password. It's more secure that way. Beyond that, it would be a simple modification to actually have that cookie generate a login rather than just pre-fill the name. However, I think the username thing is a good first step because I'm wary of session-hijacking and would like some of the more security-minded folks to weigh in.
Comment #5
joshk commentedOk. Got the thumbs-up from chx, with sepeck and rokerr confirming what I thought. I'll start rolling a patch now.
Here's the IRC log on security question:
Comment #6
joshk commentedHere's a patch. It's a biggun, so let me break it out:
1) Updates the .install file to create a table to store rememberme data: a sid, a username, a uid and a timestamp
2) Adds a rememberme tab to the admin/settings/logintoboggan screen with the following functions:
- Tells admins how long PHP's sessions will run for
- Activate rememberme for logins? No / With Checkbox / Always
- Lifetime for remembering logins
- Activate rememberme for usernames? No / With Checkbox / Always
- Lifetime for remembering usernames
3) Adds a checkbox to user login forms if either of the settings are "with checkbox"
4) If user logs in, their login and/or uid are stored in the rememberme sessions table and a cookie is set.
5) If an anonymous user comes to the site and a LTRM_session cookie is present and a session row is present with a user id and the lifetime for remembering logins (#2) has not expired, the user is seamlessly logged back in. A watchdog notice fires here as well.
6) If an anonymous user comes to the /user/login PAGE and a LTRM_session cookie is present and a session row is present with a login name and the lifetime is good, the username field is pre-filled. Also, if page caching is OFF, we'll try to pre-fill user-login BLOCKS as well.
THINGS TO IMPROVE/REVIEW:
A) Currently I'm using hook_init to do the re-login. It seems to work fine, but I'd like some vetting on this.
B) Also in hook_init, I am keeping the cache clear for the /user page, which is necessary for the pre-fill option to work.
C) I've tried to copy best-practices in terms of how the cookie is set and the session lifetime maintained, but review is probably in order here.
I've commented the code a fair amount. Let me know how this looks! I have yet to dig into the changes for HEAD/5.0, but will do if this is acceptable.
Comment #7
joshk commentedFixed bug in .install file's upgrade hook. Use this patch instead.
Comment #8
fatfish commentedfollowUp
Comment #9
joshk commentedI've been using this now for a week on two of my sites. No problems so far.
Comment #10
hunmonk commentedcouple of things:
Comment #11
joshk commentedThere's actually a separate module that does this already, although I don't know how good it is or if it plays well w/the toboggan but (sylistic difference) I'm a fan of convergance rather than a million modules. But then I'm not the maintainer, so I see your point too. ;)
This is a bit different from the old 4.3-era checkbox, in that the method then was to change the session cookie's lifespan, like so:
This didn't always work very well, and is incompatible with ussing PHPs own built-in sessioning I think. My patch uses it's own independent cookie, which works every time.
I'll probably just try and improve the other module (or be ashamed I didn't look for it before writng my own code).
Comment #12
senthiln commentedMost of the discussion here is for adding remember me feature to logintoboggan for version 4.7.x So I applied a similar change to logintoboggan 4.6 version. Now remember me feature works fine for my drupal 4.6 site. If you have any doubt, look at http://supplychain-logistics.com Feel free to change the code or contact me. Code is attached to this post.
Comment #13
hunmonk commentedwhy is this marked fixed? it hasn't been applied to the CVS version of the module, so it certainly isn't fixed. :)
also, this is a feature request and not a task.
Comment #14
Gary Feldman commentedIt appears that the Persistent Login module (http://drupal.org/project/persistent_login) already provides this behavior for 4.7 and 5.0. If absolutely needed for 4.6, it would probably make more sense to backport that module than add it here.
So I'm marking this "won't fix."