Skip to content

Instantly share code, notes, and snippets.

@volpeo
Created September 14, 2016 10:20
Show Gist options
  • Save volpeo/054af66d430cd518ba12ffdc65a34bfb to your computer and use it in GitHub Desktop.
Save volpeo/054af66d430cd518ba12ffdc65a34bfb to your computer and use it in GitHub Desktop.
Redirect from a satellite static website to application
# create cookie at sign in
cookies[:redirect] = {
:value => 'yes',
:expires => 1.year.from_now,
:domain => '.mydomain.com'
}
# delete cookie at sign out
cookies.delete :redirect, domain: '.mydomain.com'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.3/js.cookie.js"></script>
<script>
var redirect = Cookies.get('redirect');
if (redirect == "yes") {
window.location.href = "http://app.mydomain.com";
}
</script>
</head>
<body>
<h1>Should be redirected if connected on the app</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment