Flow:
- 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']
the aboe flow works perfect for first browser tab, if user has multiple tabs open then $_GET['ref']
gets set to same URL that is set for first tab. For example:
EXAMPLE:
Tab 1 : /somepage/hello/world
Tab 2: /another/page/1
when user logs out from Tab 1 gets redirected to:
/login?ref=http://site.com/somepage/hello/world (CORRECT)
If user refreshes the page on Tab 2 gets redirected to:
/login?ref=http://site.com/somepage/hello/world
NOT CORRECT, IT SHOULD REDIRECT TO:
/login?ref=http://site.com/another/page/1
Don't redirect anywhere. Handle the re-login process on the same URL the user is already on. This will keep the URL of every tab and browser window intact.