I have a web site which shows different content based on a location
the visitor chooses. e.g: User enters in 55812
as the zip. I know what
city and area lat/long. that is and give them their content pertinent
to that area. My question is how can I store this in a cookie so that
when they return they are not required to always enter their zip code?
I see it as follows:
- Set persistent cookie based on their area.
- When they return read cookie, grab zipcode.
- Return content based on the zip code in their cookie.
I can't seem to find any solid information on setting a cookie. Any help is greatly appreciated.
UPDATE : check Peter's answer below for a builtin solution :
This is a helper to set a persistent cookie:
Use the following code before sending a response.
UPDATE : check Peter's answer below for a builtin solution :