i hate my life because I do not know what Im doing

im trying to leave a cookie on the users pc from the URL.

THIS IS THE URL (generated by infusionsoft)
http://www.get-financed.org/rtest/2/?Contact0Email=pleasegodwork@jjsjs.com&contactId=40939

The URL contains something called contactId and im using this code

// set the cookies
setcookie("cookie[three]", "<?=$_GET['contactId']?>");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");

// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
    foreach ($_COOKIE['cookie'] as $name => $value) {
        echo "$name : $value <br />\n";
    }
}
print_r($_COOKIE);

The reason why i think this would work is because down in the page im using this... and its working

<td><input name="contactId" size="15" id="contactId" value='<?=$_GET['contactId']?>' type="text" class="default-input" /></td>

How can I get the contact id ( 40939 ) to print as a cookie so i can look for it when users hit other pages?

Even if you do not help, please laugh so that my 8 straight hours it took to get this far produces some value for someone.

Recommended Answers

All 6 Replies

Member Avatar for diafol

i hate my life because I do not know what Im doing.

Want to borrow a rope? Or, I could let you have a second-hand gas oven for £30. Sound good?

Place your code in code tags when you re-post.

If you are using a cookie just to identify a user why not use $_SESSION to hold the user id ?

Want to borrow a rope? Or, I could let you have a second-hand gas oven for £30. Sound good?

Place your code in code tags when you re-post.

my husband killed himself last night... thanks alot

Probably best not to serve cookies at the wake then ;)

If you are using a cookie just to identify a user why not use $_SESSION to hold the user id ?

I cant use session for a reason thats too long to really explain... essentially it has to do with the customer watching a video and being told to go type in a URL for a special discount (this converted higher than having a button)

so the URL they type in will look for the cookie and this page will store the cookie (from the URL) and thats what I cant find out how to do..

Seems like what you have should work, setting the cookie is pretty straightforward.

setcookie("contact_id", $_GET['contactid'], time()+60*60*24*60, "/");

// This cookie will expire in 60 days

What exactly is the problem? Not returning the value of the cookie? Cookie not setting ??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.