confirmation Posted April 6, 2013 Share Posted April 6, 2013 <?php if(isset($_POST['login']) AND isset($_POST['password'])){ $username = addslashes($_POST['login']); $username = htmlspecialchars($username); $password = addslashes($_POST['password']); $password = htmlspecialchars($password); $passwordm = md5($password); $passwordmd5xx = "XXXXXXXXXX".$passwordm; if(!empty($username) AND !empty($password)){ include('../includes/functions.php'); $query = mysql_query("SELECT * FROM `users` WHERE user_login='".$username."' AND user_pass='".$passwordm."' AND user_status='1'") or die ("Query failed"); $counts = mysql_num_rows($query); if($counts == 0){ include('index.php'); }else{ $rows = mysql_fetch_array($query); setcookie("user_id",$rows['user_id'],time()+14400); setcookie("user_pass",$passwordmd5xx,time()+14400); echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=tools.php'>"; mysql_close($connectdb); } }else{ include('index.php'); } }else{ include('index.php'); } ?> i'm using this code to connect into my panel administration... for some reason there is no cookies set when i'm try to login... ( no cookies => no login ) when i debug the $_COOKIE it return an empty array !! this code work just fine in localhost and the stranger thing it work also in another web server, but not in this web server that i'm using actually... i can't understand where is the problem ?! any suggestion are welcome thank you Quote Link to comment https://forums.phpfreaks.com/topic/276612-cookie-cant-be-set/ Share on other sites More sharing options...
Rifts Posted April 7, 2013 Share Posted April 7, 2013 Maybe try setcookie( "name", "value", "future_timestamp", "path", "domain" ); I thought the path and domain was required. Quote Link to comment https://forums.phpfreaks.com/topic/276612-cookie-cant-be-set/#findComment-1423355 Share on other sites More sharing options...
teynon Posted April 7, 2013 Share Posted April 7, 2013 Can you verify that the code is actually reaching "setcookie" and not being sent back to the index.php in the count check? IE The database query might be returning no results. Quote Link to comment https://forums.phpfreaks.com/topic/276612-cookie-cant-be-set/#findComment-1423357 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.