Can I use get info as a fallback if cookie not set?

My index page will be a form to enter the visitors zip code. The zip code will be used to set a cookie named zip, and the visitor will be returned a php page with the same info in the URL. The URL would be something like ;

Mysite.com/local.php?zip =12345

The zip =12345 will be the get info available for use.
This means that the zip =12345 is both stored as a cookie and appended to the URL.

When a visitor hits the index page, if they have a cookie, then they would be forwarded to Mysite.com/local.php. That page would need to get the zip information from the cookie, because it bypassed the process that added the get info to the URL. There will be other ways a visitor could be sent to that page, and under those circumstances, the? Zip =12345 would be included in the URL.

My question is, can a php script check for the cookie first, and if not found, use the get info to create the page?

Yes.

It is straight forward, first check $_COOKIE, and if it is not set check for $_GET value, and if its not set redirect back to index.

Great. Thanks for replying

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.