codejoust / session.js

Session.js - Get user session information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Utilize localStorage or sessionStorage if available.

yahelc opened this issue · comments

It'd be great if session.js utilized localStorage (or sessionStorage) if available.

Using cookies with this much data in them can have performance implications.

After one visit, my first_session cookie was 526 bytes and location cookie was 257 bytes. That's 783 extra bytes per request. If the point is for this information to be used on the client, there's no reason to add that weight to every HTTP request. On a page with 100 requests, that's an extra 76kb of bandwidth per load.

Happy to provide a pull request if you'd like.

commented

Go for it.

You'll probably want to hook into the get_obj and set_obj methods to do that. Shouldn't be too hard.

Also, it would be great if you used the testing suite in the test folder. (Just open the TestRunner.html file in your browser, you'll need to use a local webserver like python -m SimpleHTTPServer).

commented

Another way to slim down cookie size would be to remove the parsed referrer url and page url from the session object, and have it dynamically add that to the object from the raw url.

commented

The hooks for set_obj and get_obj are now setup.