Wipeout Posted May 22, 2008 Share Posted May 22, 2008 I have been trying to put a setcookie into my session class and i can't work it out. i want the user to login and the cookie will keep the user logged in for 2 weeks which is time()+1209600 If anyone can add it for me i will be most grateful heres my code: <?php mysql_connect("$dbserver","$dbuser","$dbpass") or die(mysql_error()); mysql_select_db($dbdata) or die(mysql_error()); $d=$_GET[d]; if($d=="") $d=$_POST[d]; $s=$_GET[s]; if($s=="") $s=$_POST[s]; $u=$_GET[u]; if($u=="") $u=$_POST[u]; session_name("cls"); session_start(); if($_SESSION[user]!="") $user=$_SESSION[user]; if($_SESSION[pass]!="") $pass=$_SESSION[pass]; if($_POST[user]!="") $user=$_POST[user]; if($_POST[pass]!="") $pass=$_POST[pass]; $encrypt_pass=md5($pass); if($user!="" && $pass!="" && $d!="logout") { $mdc = mysql_query("SELECT * FROM user WHERE user = '".addslashes($user)."' AND pass = '".addslashes($encrypt_pass)."'"); $usrd = mysql_fetch_array($mdc); if($usrd[id]!="") { $_SESSION[user] = $user; $_SESSION[pass] = $encrypt_pass; $lg="ok"; mysql_query("UPDATE user SET online='".time()."' WHERE id='".$usrd[id]."'"); } else { session_unset(); $lg=""; } } else { session_unset(); $lg=""; } ?> Link to comment https://forums.phpfreaks.com/topic/106796-cookie-logged-in-time/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.