Posts

Showing posts with the label Cookies

Check If Httponly Cookie Exists In Javascript

Answer : You can indirectly check to see if it exists by trying to set it to a value with javascript if it can't be set, then the HTTP Only Cookie must be there (or the user is blocking cookies). function doesHttpOnlyCookieExist(cookiename) { var d = new Date(); d.setTime(d.getTime() + (1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cookiename + "=new_value;path=/;" + expires; if (document.cookie.indexOf(cookiename + '=') == -1) { return true; } else { return false; } } No. And see Rob's comments below. See this, which you probably already saw - http://en.wikipedia.org/wiki/HTTP_cookie#Secure_and_HttpOnly An HttpOnly cookie is not accessible via non-HTTP methods, such as calls via JavaScript (e.g., referencing "document.cookie")... Edit: Removed undefined response, I wrote a script that you may not be using :) I had the same problem. I solved it with the server setting anoth...

Can I Limit The Length Of An Array In JavaScript?

Answer : You're not using splice correctly: arr.splice(4, 1) this will remove 1 item at index 4. see here I think you want to use slice: arr.slice(0,5) this will return elements in position 0 through 4. This assumes all the rest of your code (cookies etc) works correctly The fastest and simplest way is by setting the .length property to the desired length: arr.length = 4; This is also the desired way to reset/empty arrays: arr.length = 0; Caveat: setting this property can also make the array longer than it is: If its length is 2, running arr.length = 4 will add two undefined items to it. Perhaps add a condition: if (arr.length > 4) arr.length = 4; Alternatively: arr.length = Math.min(arr.length, 4); arr.length = Math.min(arr.length, 5)

Can I Create A New Session In Another Tab Or Window In Google Chrome?

Answer : Currently, this is not possible. You can use multiple profiles in Google Chrome, though. Read the instructions here. Enable multiple accounts: https://www.google.com/accounts/MultipleSessions Then, create a bookmark(let) or a keyboard shortcut for each mailbox: https://mail.google.com/mail/u/0/#inbox https://mail.google.com/mail/u/1/#inbox Source: http://lifehacker.com/5733636/switch-between-multiple-gmail-accounts-with-a-url-hack MultiLogin is down from the google webstore, but there is an alternative (SessionBox) https://chrome.google.com/webstore/detail/sessionbox-beta/megbklhjamjbcafknkgmokldgolkdfig