Jump to content

Help with cookies


jimmyp3016

Recommended Posts

Hey Guys,

 

I need some help with cookies. What im trying to do is store an refferer id so if someone comes back to my webpage, the person who reffered them will get the credit. Here is what I have but it does not store the cookie.

Any help ASAP would be much appreciated.

 


$ref = $_REQUEST['referer'];

                         if ( !$ref )
	$ref = -1;

if(isset($_COOKIE['mysite']))
	{ 
	echo ""; 
	} 
else 
	{ 
	$Month = 2592000 + time(); 
	setcookie(mysite, $ref, $Month);
	} 

Link to comment
Share on other sites

Thanks for the quick response.

 

I dont think its pulling the cookie once its set because I have a hidden value in my form

 

<?php if ($_REQUEST['ref']) echo "<input type=\"hidden\" name=\"referer\" value=\"".$_REQUEST['ref']."\" />"; ?>

 

If I hit mysite.com?ref=4

 

That hidden value shows 4 and should store a cookie

 

But if i then go to mysite.com

 

it should pull the cookie and show the hidden value of 4 but it doesnt.

 

Any thoughts?

Link to comment
Share on other sites

Ok,

 

disreguard my last post

 

by doing a

 

print_r($_COOKIE);

 

It DOES display my stored cookie and the ref value.

 

My only question is how can I get that value to populate my hidden form value of

 

<?php if ($_REQUEST['ref']) echo "<input type=\"hidden\" name=\"referer\" value=\"".$_REQUEST['ref']."\" />"; ?>

 

Do i request the cookie instead?

Link to comment
Share on other sites

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.