garethhall Posted August 3, 2009 Share Posted August 3, 2009 Hi guys maybe you can help me out here. This it the first time I am using cookies and I can't seem to to get the the cookie value. The odd thing is I can see the cookies when I check them through the browser they go a name and value. I have 2 different scripts 1 the processLogin.php This is where you login <?php require_once("clientConn.php"); include("sharedFunctions.php"); session_start(); //Set Variables $loginName = checkVars($_POST['loginName']); $password = checkVars(base64_encode($_POST['password'])); $time = time(); $remember = $_POST['remember']; $msg = ""; if(isset($_POST['confirm']) && $_POST['loginName'] != "" && $_POST['password'] != ""){ $sql_mem = "SELECT * FROM members WHERE (memName = $loginName OR memEmailAddress = $loginName) AND memPassword = $password"; $rs_mem = mysql_query($sql_mem, $client); $fnd_mem = mysql_num_rows($rs_mem); $rw_mem = mysql_fetch_assoc($rs_mem); if($fnd_mem){ $_SESSION['kbsLogin'] = 1; if($remember){ setcookie("kbsMemID",$rw_mem['memID'], $time + 3600*24*90); setcookie("kbsLoginName",$loginName, $time + 3600*24*90); setcookie("kbsPassword",$password, $time + 3600*24*90); } header("Location: ../accountoverview.php"); exit(); }else{ header("Location: ../login.php?e=1"); exit(); } }else{ header("Location: ../login.php?e=2"); exit(); } ?> and 2 sharedFunctions.php here I check to see if the member is logged in <?php //********************* initialize the session *************************** if (!isset($_SESSION)) { session_start(); } //************************ Protect Variables from SQL injection ***************************** function checkVars($value){ // Stripslashes if (get_magic_quotes_gpc()){ $value = stripslashes($value); } // Quote if not a number if (!is_numeric($value)){ $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } //**************************************** User and session authentication ************************************************** function auth(){ echo $_COOKIE['kbsMemID']; echo $_COOKIE['kbsLoginName']; echo $_COOKIE['kbsPassword']; if(isset($_COOKIE['kbsMemID']) && isset($_COOKIE['kbsLoginName']) && isset($_COOKIE['kbsPassword'])){ $memID = $_COOKIE['kbsMemID']; $loginName = $_COOKIE['kbsLoginName']; $pass = $_COOKIE['kbsPassword']; $sql_mem = "SELECT * FROM members WHERE (memName = $loginName OR memEmailAddress = $loginName) AND memPassword = $password AND memID = $memID"; $rs_mem = mysql_query($sql_mem, $client); $fnd_mem = mysql_num_rows($rs_mem); $rw_mem = mysql_fetch_assoc($rs_mem); if($fnd_mem){ $_SESSION['kbsLogin'] = 1; }else{ echo "not logged in"; exit(); } } } Quote Link to comment Share on other sites More sharing options...
realjumper Posted August 3, 2009 Share Posted August 3, 2009 What about using double quote....I do. echo $_COOKIE["kbsMemID"]; echo $_COOKIE["kbsLoginName"]; echo $_COOKIE["kbsPassword"]; Quote Link to comment Share on other sites More sharing options...
garethhall Posted August 3, 2009 Author Share Posted August 3, 2009 Tried it No,luck doubles no go Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.