相同的Referer URL为具有不同URL的两个不同浏览器选项卡打开PHP


Same Referer URL opens for two different browser tabs with different URLs PHP

流量:

- user visits a page say www.mysite.com/somepage/1
- user clicks on Log Out button or times out and logs out
   *user log out detected redirect to home page but save the referer URL
   *redirect to /login?ref=$_SERVER['HTTP_REFERER'] (actual code test if its set)
- user sees login page and relogs back
- user is redirected back to refere url that is saved in $_GET['ref']

上面的流程非常适合第一个浏览器选项卡,如果用户打开了多个选项卡,则$_GET['ref']将被设置为与为第一个选项卡设置的URL相同的URL。例如:

示例:

  Tab 1 : /somepage/hello/world
  Tab 2: /another/page/1

当用户从选项卡1注销时,将重定向到:

/login?ref=http://site.com/somepage/hello/world (CORRECT)

如果用户刷新选项卡2上的页面,则被重定向到:

/login?ref=http://site.com/somepage/hello/world 
   NOT CORRECT, IT SHOULD REDIRECT TO: 
/login?ref=http://site.com/another/page/1

不要重定向到任何位置。在用户已登录的URL上处理重新登录过程。这将保持每个选项卡和浏览器窗口的URL不变。