// tests whether the user has cookies enabled by setting a cookie // and then trying to retrieve it back. If a "true" argument is passed // then this function attempts to test whether persistant cookies // (i.e. non session cookies) are enabled.
function testClientCookies() { var testPersistant = false; if (arguments.length > 0) testPersistant = arguments[0]; if (testPersistant) { // save a new cookies with an expiration date set to 5 seconds from now var now = new Date(); var cookiedate = new Date(now.valueOf() + 1000*5); document.cookie = "cookieTest=persist;expires=" + cookiedate.toGMTString(); } else { // save a session cookie (no expiration specified = lives for the // lifetime of the browser) so that we check for any kind of cookies document.cookie = "cookieTest=session" } if ((document.cookie).indexOf("cookieTest") == -1) { // cookie not found; all cookies must be disabled return false; } else { return true; } } // testClientCookies // function of client-side check(s) that are made when the user tries to log in
function doLoginTimeChecks() { // test if Session-cookies (at least) are enabled if (testClientCookies()) { document.forms['loginForm'].cookieTest.value = '1'; } // we cannot test if JavaScript is enabled (because the test itself would // have to be written in JavaScript) but we can set a variable that will // be looked at by login.asp when the user submits the form
document.forms['loginForm'].JavaScriptTest.value = '1'; return true; }
// If you use "Remember Me" checkbox along with login / password, this section is needed. // This function will be called //
function rememberMeClick() { if (document.forms['loginForm'].rememberMe.checked == true) { // first check if cookies are enabled at all so that we don't // inaccurately claim that "only session cookies are enabled" if (!testClientCookies) { window.location = http://efwinslow.com/building36login?m=cookies_off&browser=' + browserCode; return; }
// check for non-session cookie (pass true as argument) if (!testClientCookies(true)) { alert('In order to take advantage of Alarm.com\'s "Remember My Login" feature, you must allow cookies to be stored on your computer.'); document.forms['loginForm'].rememberMe.checked = false; } } }
Please login to your Building 36 account below