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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Cookie

Status
Not open for further replies.

DaveyRichards

Programmer
Nov 8, 2006
14
GB
Hey all.

Am having a problem with my cookie. I have a drop down menu whereby on submission the selected value is stored within a cookie. My problem is that I am trying to display the value of this cookie on the page that has been submitted to, but it seems the cookie is not being set until after the page has loaded and therefore I am receiving the previous value of the cookie as opposed to the value recently submitted.

Refreshing the page shows the correct value. I know that setting a cookie must go before the HTML and that is where I have it.

Anybody any suggestions?
 
php sets cookies in pages that get sent to the browser. so you cannot both set a cookie and retrieve that cookie's value in the same instantiation of the script.

you could set the cookie in javascript and then retrieve it the next time that the page is requested from the browser.

but why would you need to address the value of the cookie that you have just set (in the same script)? you know what the value is because you have just set it!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top