Skip to content

Instantly share code, notes, and snippets.

@cezarypiatek
Created June 25, 2016 10:13
Show Gist options
  • Save cezarypiatek/c47aeb74a5fd31383ed97dfc807258e0 to your computer and use it in GitHub Desktop.
Save cezarypiatek/c47aeb74a5fd31383ed97dfc807258e0 to your computer and use it in GitHub Desktop.
function getNewTabId(){
return Math.ceil(Math.random()*1000000000).toString();
}
function deactivateTabSession(){
}
var tabIdKey ="__TAB_ID__";
if(sessionStorage.getItem(tabIdKey) == null)
{
var newTabId = getNewTabId();
sessionStorage.setItem(tabIdKey, newTabId);
localStorage.setItem(tabIdKey, newTabId);
}else if(sessionStorage.getItem(tabIdKey) != localStorage.getItem(tabIdKey))
{
deactivateTabSession();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment