Skip to content

Instantly share code, notes, and snippets.

@nonbreakingspace
Last active December 17, 2015 13:19
Show Gist options
  • Save nonbreakingspace/5616832 to your computer and use it in GitHub Desktop.
Save nonbreakingspace/5616832 to your computer and use it in GitHub Desktop.
Add a session ID to a URL
<script type="text/javascript">
/*
var session = getParameterByName( 'session' );
if ( !session || session == '' ) {
var date = new Date();
var url = window.location.origin + window.location.pathname + '?session=' + date.getTime();
window.location.replace( url );
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
*/
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment