newbie69 Posted June 25, 2008 Share Posted June 25, 2008 Hi guys, I seem to be have problems with setting cookie. The code below is example of the problem i have: <?php $affliate_src = (isset($_GET['src'])) ? $_GET['src'] : 'QuickbooksSite'; setcookie("affliate",$affliate_src, time()+2592000); echo $_COOKIE['affliate']; ?> in the above code i set the cookie, but why does the it NO print the cookie info to the screen when i call it? It only does this when i refresh. I need to have it read straight away, with out using sessions? Any ideas. I need the cookie to be read straight away without the page being refreshed. Please please please, urgent help needed. Sudhir Link to comment https://forums.phpfreaks.com/topic/111797-solved-cookies-urgent-help-please/ Share on other sites More sharing options...
Stephen Posted June 25, 2008 Share Posted June 25, 2008 I believe it's spelled "affiliate" if you're worried about spelling errors if anyone else views it. But uhm, try changing $affliate_src to something different. if (isset($_GET["src"])) { $_affliate_src=$_GET["src"]; } I'm not sure what QuickbooksSite is suppose to do/be. Please explain what you want to do. Link to comment https://forums.phpfreaks.com/topic/111797-solved-cookies-urgent-help-please/#findComment-573922 Share on other sites More sharing options...
rupam_jaiswal Posted June 25, 2008 Share Posted June 25, 2008 Hi, u can't get a cookie's value if u r setting and printing the cookie in the same page. for that u will have to move to next page. Link to comment https://forums.phpfreaks.com/topic/111797-solved-cookies-urgent-help-please/#findComment-573925 Share on other sites More sharing options...
Stephen Posted June 25, 2008 Share Posted June 25, 2008 Hi, u can't get a cookie's value if u r setting and printing the cookie in the same page. for that u will have to move to next page. You don't need to move to the next page. You can set the cookie and display it on the same page. EDIT: Although you may have to refresh, so I see why you would want it on the next page. Link to comment https://forums.phpfreaks.com/topic/111797-solved-cookies-urgent-help-please/#findComment-573928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.