Jump to content

[SOLVED] COOKIES, URGENT HELP PLEASE


newbie69

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.