-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
38 lines (31 loc) · 1.24 KB
/
login.php
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
<?php
require_once 'user_account.php';
ini_set('session.gc_maxlifetime', 60 * 60); // one hour
session_start();
$redirect = $_POST['returnto'];
echo "\$redirect = $redirect";
// Proceed if username and password were submitted.
if (isset($_POST['user']) && isset($_POST['pass'])){
// if username and password are valid, log user in
if (login($_POST['user'], $_POST['pass']) == LOGIN_SUCCESS)
{
// save username in cookie for a day
setcookie("user", $_POST['user'], time() + 1 * 24 * 60 * 60);
// save password in, ack, cookie for a week if requested
if ($_POST['keep'])
setcookie("pass", $_POST['pass'], time() + 1 * 24 * 60 * 60);
// redirect user to index page, using absolute path, per
// http://us2.php.net/manual/en/function.header.php
$host = $_SERVER['HTTP_HOST'];
$path = rtrim(dirname($_SERVER["PHP_SELF"]), "/\\");
header("Location: http://$host$path$redirect");
}
}
else {
// redirect user to index page, using absolute path, per
// http://us2.php.net/manual/en/function.header.php
$host = $_SERVER['HTTP_HOST'];
$path = rtrim(dirname($_SERVER["PHP_SELF"]), "/\\");
header("Location: http://$host$path$redirect");
}
?>