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 !!!! Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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); ??? Quote Link to comment 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 ! ??? Quote Link to comment 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. Quote Link to comment 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 ? 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.