Optimalworks Ltd web design, SEO, training and consultancy 

the site completely surpassed my expectations GT, AutoDirector, we build websites that work, my website is great - I love it MP, XL Autos, reach more customers, make more sales, it's more than I ever could have expected LM, Trade Cars UK, we can help your business grow, 99% of business now comes from my website GV, Bash Events, promoting standards throughout the web industry, your contribution added a level of quality we would otherwise have struggled to achieve PS, Hemsley Fraser
  1. home
  2. Services
  3. Portfolio
  4. Contact us
  5. blog

JavaScript session variables without cookies

written by Craig, 14 May 2008

Cookie handling in JavaScript – or any language – can easily catch you out. Cookies are limited in number and size and they’re easy to block. However, here’s a fantastic idea that allows you to safely store up to 2Mb of session data without using cookies: Session variables without cookies.

It works using the window.name property (or, more specifically, top.name – the top-level parent frame). It appears that .name can hold a string of almost any length (depending on the browser) and the value survives between page loads – even if you visit another domain.

This means that you can serialise huge objects and store them on the client. Unlike cookies, you can also do this without sending any data to the server. It’s a very clever solution and could be used to obtain and store the user’s preferences at the start of the web application’s session.

Just remember that storing lots of session data on the client isn’t robust and it won’t be fast either!

  • categories: javascript
  • tags: javascript
  • trackback: http://www.optimalworks.net/blog/2008/web-development/javascript/javascript-nocookie-sessions/trackback
  • bookmark: del.icio.us, digg, facebook, twitter, reddit, Furl, Spurl, Blinklist, Slashdot, Technorati, Yahoo!
add your comments
please enter your name
please enter your email address - it will not be published anywhere
please enter your website address
please enter your comments (all are moderated and checked for spam)
  • next article: Petition to save Bletchley Park 
  • previous article: BetterInnerHTML v1.15 update – an innerHTML alternative 
search
  • all popular (5)
  • courses (1)
  • general (4)
  • hardware (1)
  • software (30)
    • blogs (1)
    • free download (7)
    • web browsers (12)
    • web servers (2)
  • web development (36)
    • accessibility (4)
    • ajax (1)
    • css (2)
    • graphic design (4)
    • html (1)
    • javascript (9)
    • php (4)
    • seo (2)

tags

  • accessibility
  • ajax
  • apache
  • award
  • chrome
  • computing
  • css
  • design
  • developers
  • dom
  • download
  • editor
  • emulation
  • firefox
  • funny
  • graphics
  • hardware
  • html
  • ie
  • javascript
  • opera
  • php
  • png
  • portfolio
  • review
  • safari
  • security
  • seo
  • server
  • software
  • spam
  • ssl
  • standards
  • wordpress
  • xml
  1. site map
  2. home
  3. Services
  4. Portfolio
  5. Contact us
  6. blog
  7. RSS feed
  8. project survey

XHTML 1.0 | CSS 2.1 | WAI AAA | printer-friendly

©2010 Optimalworks Ltd, Devon, UK. Registered in England and Wales No. 5922205.

This page can be viewed at http://www.optimalworks.net/blog/2008/web-development/javascript/javascript-nocookie-sessions