Session Management in Mojito


is there a way to handle/manage sessions in Mojito?


5 Replies
  • You might find this useful


    Note: It is not battle ready.

  • @Akshar, thanks for sharing the gist. A couple of recommendations:

    1- you can create a npm package with your addon, and whoever wants to use it, just need to add it to the app dependencies instead of copying the code into their app. Here is a similar example: https://github.com/caridy/mojito-alter-mojit

    2- dependsOn directive is deprecated in favor of the regular YUI requirements. Just make sure you require mojito-http-addon instead.

    3- This Y.MemoryStore[this.sessionCookie] is problematic on the server side because you don't have a mechanism to clean up that structure. Keep in mind that on the server side, memory will continue to build up over time. That's why, in the majority of the cases, you should offload that into a different layer, saying memcache, redis, or whatever persistent and shared layer with the clean up mechanism built-in. The other option here is to use Y.Cache with a max value that is configurable per app, so memory will be recovered for old sessions.

  • Thanks Caridy.

    Will work on this. As far as point 3 is concerned I thought of using redis but that only increases the friction to get started. Y.Cache seems like a good option to begin with.

  • @caridy

    I have created an npm module with your suggestions incorporated. Currently I am using Y.Cache but I am thinking to providing redis alternatives as well.

    To install the addon:

    npm install mojito-session-addon

    Github: https://github.com/akshar100/mojito-session

  • Awesome work. We plan to have a page with all mojito related packages, I will make sure we add your component as well.


Recent Posts

in Yahoo! Mojito