asmith Posted November 18, 2007 Share Posted November 18, 2007 hi i'm studing php with a book in a "login page" i put these lines : if ($num !=0) \\ $num for mysql_num_rows which identied the user {setcookie("aaa","bbb",time()+1800,"/","127.0.0.1",0); $displayblock = "<a href=\"a.php\"> a page </a>";} else {$displayblock = "your username and password do not match!";} . . . echo $displayblock ; when i load this page and sign in i can see the a page link , but my browser do not warn me about recieving cookie (and no "eye" icon in the status bar (each IE 6 and FF 2)) and in a.php i have at the top : if ($_COOKIE[aaa] == "bbb") {$msg="hello !!!";} else {header("location: /loginpage.html"); exit; } . . . and when i click in a page link , it shows up the login page again which means $_COOKIE didn't worked... please help !!!! Link to comment https://forums.phpfreaks.com/topic/77811-_cookie/ Share on other sites More sharing options...
pranav_kavi Posted November 18, 2007 Share Posted November 18, 2007 f ($_COOKIE[aaa] == "bbb") {$msg="hello !!!";} else {header("location: /loginpage.html"); exit; } . . . and when i click in a page link , it shows up the login page again which means $_COOKIE didn't worked did u xpect $msg to display on clickin d page link..in tat case wher s the echo statement for $msg? Also check your cookie settings for the browser. Link to comment https://forums.phpfreaks.com/topic/77811-_cookie/#findComment-393820 Share on other sites More sharing options...
asmith Posted November 18, 2007 Author Share Posted November 18, 2007 does that make any diffrence? at down of that page where $msg = "hello!" in the body tag , <body> <?php echo $msg; ?> ... i can't get it working don't know why , the book has written you browser should alert you about recieving a coockie, but i've got nothing, then again i've looked at IE option , i can't find cookie option , but in fire fox the option goes to cookie has checked , nothing wrong is with FF cookie option it is "allowed" . what is it i'm doing wrong? Link to comment https://forums.phpfreaks.com/topic/77811-_cookie/#findComment-393829 Share on other sites More sharing options...
pranav_kavi Posted November 18, 2007 Share Posted November 18, 2007 Have u tried printing out the cookie array i.e print_r($_COOKIE); ??? Link to comment https://forums.phpfreaks.com/topic/77811-_cookie/#findComment-393833 Share on other sites More sharing options...
asmith Posted November 18, 2007 Author Share Posted November 18, 2007 what to do exactlly ? $abc=print_r($_cookie) and echo it ? btw it seems i have no cookie aaa set to bbb , it means no cookie ! maybe i should ask why that cookie function idn't work ? but it has worked, i got no erroe ! ??? Link to comment https://forums.phpfreaks.com/topic/77811-_cookie/#findComment-393837 Share on other sites More sharing options...
pranav_kavi Posted November 18, 2007 Share Posted November 18, 2007 print_r($_COOKIE) wud display all the cookie values.As $_COOKIE is an array,we cannot use echo on it,have to use print_r command. Link to comment https://forums.phpfreaks.com/topic/77811-_cookie/#findComment-393841 Share on other sites More sharing options...
asmith Posted November 18, 2007 Author Share Posted November 18, 2007 anyone out there help me ? why my coockie does not work ? Link to comment https://forums.phpfreaks.com/topic/77811-_cookie/#findComment-394104 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.