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" Link to comment https://forums.phpfreaks.com/topic/102659-problem-with-retrieving-info-from-a-cookie/ 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); Link to comment https://forums.phpfreaks.com/topic/102659-problem-with-retrieving-info-from-a-cookie/#findComment-525789 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? Link to comment https://forums.phpfreaks.com/topic/102659-problem-with-retrieving-info-from-a-cookie/#findComment-525790 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? Link to comment https://forums.phpfreaks.com/topic/102659-problem-with-retrieving-info-from-a-cookie/#findComment-525795 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 >_< Link to comment https://forums.phpfreaks.com/topic/102659-problem-with-retrieving-info-from-a-cookie/#findComment-525797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.