From 911d0baa7862a6e1e0c9129ab4177ff9712a319c Mon Sep 17 00:00:00 2001 From: Wesley Miaw Date: Fri, 14 May 2004 21:09:16 +0000 Subject: Implemented user login via cookies and/or sessions with templates. --- functions/userauth_functions.php | 143 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 functions/userauth_functions.php (limited to 'functions/userauth_functions.php') diff --git a/functions/userauth_functions.php b/functions/userauth_functions.php new file mode 100644 index 0000000..403076d --- /dev/null +++ b/functions/userauth_functions.php @@ -0,0 +1,143 @@ + $username, 'password' => $password)); + setcookie('phpicalendar_login', $the_cookie, time()+(60*60*24*7*12*10), '/', $cookie_uri, 0); + } else { + $_SESSION['username'] = $username; + $_SESSION['password'] = $password; + } + + // Return the username and password. + return array($username, $password, $invalid_login); +} + +// Logout the user. The username and password stored in cookies or the +// session will be deleted. +// +// Returns an empty username and password. +function user_logout() { + global $login_cookies, $cookie_uri; + + // Clear the login cookie or session authentication values. + if ($login_cookies == 'yes') { + setcookie('phpicalendar_login', '', time()-(60*60*24*7), '/', $cookie_uri, 0); + } else { + // Check if the session has already been started. + if (!session_id()) { + session_start(); + setcookie(session_name(), session_id(), time()+(60*60*24*7*12*10), '/', $cookie_uri, 0); + } + + // Clear the session authentication values. + unset($_SESSION['username']); + unset($_SESSION['password']); + } + + // Return empty username and password. + return array('', ''); +} +?> -- cgit v1.2.3