xcali Posted April 24, 2008 Share Posted April 24, 2008 hey guys i have a problem with retrieving information from a cookie the part of my login script creates a cookie with the following: ... // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(username, $_POST['username'], $hour); setcookie(Key_JDW, $_POST['pass'], $hour); ... then a script should retrieve the username from the cookie: the code i use it as follows: <?php echo 'Welcome to JDW' .$_COOKIE['username']. '!'; ?> i only see ' Welcome to JDW! ' Am i doing something wrong? i tried to do " " instead of ' ' i tried both "" '' i tried {$_COOKIE['username']} and such but nothing seems work can it be a problem with the way i created the cookie? edit: i should probably mention that the username they use is their email, when i open the cookie its displayed as "something%40something.com" Quote Link to comment Share on other sites More sharing options...
mrdamien Posted April 24, 2008 Share Posted April 24, 2008 Try: setcookie("username", $_POST['username'], $hour); setcookie("Key_JDW", $_POST['pass'], $hour); Quote Link to comment Share on other sites More sharing options...
xcali Posted April 24, 2008 Author Share Posted April 24, 2008 thank you for your reply same thing - just get Welcome to JDW! any other ideas? Quote Link to comment Share on other sites More sharing options...
mrdamien Posted April 24, 2008 Share Posted April 24, 2008 Is your browser accepting cookies? Try clearing your cache. Are you sure that the $_POST information is being sent? Quote Link to comment Share on other sites More sharing options...
xcali Posted April 24, 2008 Author Share Posted April 24, 2008 yes i tried in both internet explorer and Firefox and in both i get the same thing... nothing i cleared everything and logged in - cookie was created and when i view the content, it is exactly what i would like to have displayed I have been trying to to fix this problem for the past 2 days >_< 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.