Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookie not setting 1

Status
Not open for further replies.

LWolf

Programmer
Feb 3, 2008
77
0
0
US
I have done the research on setting a cookie and I cannot get it to set...

First I tried the data I needed...
Code:
if (isset($_POST['slocation'])!=""){
    	setcookie("slocation", $_POST['slocation'], time()+60*60*24*365*10;);
        echo "SLOCATION=" . $_POST['slocation'] . "<br>"; //used to see if getting into the if statement...it gets here//
    }

After the above code doesn't work I tried a basic one...
Code:
setcookie("user", "keith");

And that is not working. My browser is set to accept cookies. What am I doing wrong?!

Thanks,
K
 
i have definitely cracked that nut before. but i don't recall how. i will take a look in my archives
 
interesting. i posted that comment to a different thread. i wonder how it ended up here.

re your question above, no. post data is only sent with form submissions when the form is specified as having the method="post". links are GET requests.

if you want to pass certain data back and forth then you need to encode the data in the link so that it arrives in the $_GET and $_REQUEST superglobals..

alternatively you can use sessions. then the data is not passed back and forth but kept server side.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top