Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.