简体   繁体   中英

PHP redirect issue with Safari

I made a simple php redirect on my index page for first time users of the site to be redirected to firstvisit.htm where there are links to return to the index page

 <?php if (!isset($_COOKIE['firsttime'])) { setcookie("firsttime", "no", 0); header('Location: firstvisit.htm'); } ?> 

In all browsers (didn't test IE) the code redirects properly to my firstvisit.htm page.

on that page are links back to the index page. In all browsers but safari the links properly redirect. In Safari's case it displays the proper path in the url bar, but continues to show the firstvisit.htm page.

If the link is opened in a new tab it will function properly, and the cookie appears to be properly placed.

What would cause this and does anyone have a suggestion for a work around?

your cookie expires as soon as you set it.

try

setcookie("firsttime", "no", time() + 3600 * 24 * 30);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM