PDA

View Full Version : Webserver GetCookie/SetCookie Questions



harleydude
September 18th, 2006, 08:48 AM
I have a webpage that sets a cookie, that I will later retrieve in the same page similar to below


<%
webserver:SetCookie("Var","23",nil)
%>

<html>
....
<%
local cookies = webserver:GetCookie()
print (cookies["Var"])
%>
</html>


However, when I call the GetCookie() function cookies is an empty table. Is this normal behaviour?

Ron
September 18th, 2006, 08:53 AM
GetCookie returns the cookies passed with the request header. Meaning that a SetCookie in the SAME file will not be visible in the GetCookie! Only on next load will you see what you set. This is normal behaviour and can be found in PHP as well.

harleydude
September 18th, 2006, 09:11 AM
Ok, thats what I was thinking. I will looking into reloading the page then after the SetCookie, not a big deal.

Thanks