PersistentLogin
Description
This recipe allows users to stay logged in for several days.
Installation
1. Place persistentlogin.phpΔ to your cookbook directory (alt.download: persistentlogin.php).
2. Place the following code near the top of your (farm)config.php:
include_once("$FarmD
/cookbook/persistentlogin.php");
The above code should be placed after the <?php
line, and after any line containing session_save_path
.
The recipe should be the first included in (farm)config.php if possible, notably before AuthUser.
3. Edit your wiki page [[Site.AuthForm]]
and place the following line before the final (:input end:)
:
(:input checkbox persistentlogin 1:) $[Remember me]
Usage
When you log in, check the box "Remember me".
Configuration
Here are the settings you can customize in (farm)config.php, before including the script:
# Where to save session files, preferably inaccessible via HTTP
$PersistentSessionDir = "directory"; # default "$WorkDir
/.sessions"
# How many days of inactivity "expire" logged in users
$PersistentSessionDays = 10 ; # default 3
On some Debian-derived systems, if old session files stay in your wiki.d/.sessions directory, add also this line:
ini_set('session.gc_probability', 1);
If your wiki has more than one language, you can translate the "Remember me" string. Set in your XLPage the following (eg. for French):
'Remember me' => "Rester connecté",
Notes
- The users are kept permanently logged in, but if they do not visit the wiki for 3 days or more, they are logged out.
- Persistent logins are less secure. Never use the "Remember me" checkbox on computers which may be used by other people.
- Your browser/proxy should allow persistent cookies (some do not).
Release notes
- 20091122 - Fix for PHP 5.3 installations.
- 20090711 - First public release.
See also
- PITS:01083 Add persistent authorization option
- FixShortSessions How to fix short sessions so you aren't prompted frequently for a password
- UserAuth2 A user-based permission granting and authentication module
Author
- Recipe written and maintained by Petko.
Comments
User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.