How to redirect a user to the Last Domain Browsed I have a question, what will i do to save the last domain a user was on either on a cookie or a session or anythin else that will work so that whenever they type the main domain they are redirected to the sub domain they were on last even if the browser is closed. i have about 3 sub domains and the main domain. i am using domain access. for example

main.com &lt;== TLD
sub.main.com &lt;== Sub Domain 1
sub2.main.com &lt;== Sub Domain 2

user types in main.com and was browsing sub.main.com yesterday and instantly gets taken to sub.main.com
 and on another machine user types main.com and gets taken to last domain e.g. sub2.main.com
Help!
You need to use Cookie as Sessions will be lost once browser is closed.
You can use hook_init() or hook_boot() or page-front.tpl.php

function hook_init(){
 $domain_last_accessed = $_COOKIE['domain_cookie'];
 if($domain_last_accessed != "" &amp;&amp; $domain_last_accessed != $_SERVER['HTTP_HOST']){
 // Check if cookie is set and previous visited was not this domain then redirect
 // redirect using drupal_goto() or Header()
 }
 else{
 // Check for Cookie and set if empty, this might be the first visit or cookie was destroyed
 // SetCookie with $_SERVER["HTTP_HOST"]
 }
}


If you want it to be machine independent then you may need to store last accessed domain in DB and note that this will only help authenticated users.