I have a login script, when the user logs in a cookie is created with email ID encrypted. If cookie cant be created then a session is created to store the information. I have two types of user in my site. So along with encrypted email id, i also want to store the information about the type of user. Here is what I am doing. Please let me know is this good? or is there any other better way?
Code: Select all
// Create cookie and store login information
$cookie_name = "userlogin"; // Cookie name
$loginkey = md5($email); // Encrypted login key
$userType = "candidate"; // User type
$cookie_data = $loginkey."+|+".$userType; // Cookie data
$cookie_time = time()+60*60*60; // 1 hour
$cookie_path = "/"; // All subfolders
$cookie_domain = "domain.com"; // All subdomains
setcookie($cookie_name, $cookie_data, $cookie_time, $cookie_path, $cookie_domain);
// When cookie creation unsuccessfull
if(!setcookie){
//Store login data in session
session_start();
$_SESSION['login_key'] = md5($email);
$_SESSION['auth'] = 'candidate';
$_SESSION['first_name'] = $getAccount3['first_name'];
}Code: Select all
list($loginkey,$author) = split("+|+",$cookie_data);Thank you,