-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremember_username.php
More file actions
47 lines (38 loc) · 1.3 KB
/
Copy pathremember_username.php
File metadata and controls
47 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
if(!defined("PHORUM")) return;
function mod_remember_username_after_login($data)
{
$PHORUM = $GLOBALS["PHORUM"];
// Remember the username for a logged in user using a cookie.
if ($PHORUM["DATA"]["LOGGEDIN"])
{
$username = $PHORUM["user"]["username"];
// No cookie set or cookie differs? Then set a new cookie.
if ( !isset($_COOKIE["phorum_mod_remember_username"]) ||
$_COOKIE["phorum_mod_remember_username"] != $username )
{
setcookie(
"phorum_mod_remember_username",
$PHORUM["user"]["username"],
time() + 315360000, // expire cookie after 10 years
$PHORUM["session_path"], $PHORUM["session_domain"]
);
}
}
return $data;
}
function mod_remember_username_start_output()
{
global $PHORUM;
// Are are entering the login page?
if (phorum_page == 'login' && ! isset($_POST["username"]) &&
isset($_COOKIE["phorum_mod_remember_username"]))
{
// Replace the username with the remembered username.
$PHORUM['DATA']['LOGIN']['username'] =
$_COOKIE["phorum_mod_remember_username"];
// Make the focus shift to the password field.
$PHORUM['DATA']['FOCUS_TO_ID'] = 'password';
}
}
?>