Javascript Get previous Page example of use 

//the web api 
document.referrer

/login 
      to -> main page

//use in main page to check 
document.referrer.includes('i/login');

//result 
true