GithubHelp home page GithubHelp logo

djhi / session-store Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smeevil/session-store

0.0 2.0 0.0 104 KB

A persistent meteor session store based on amplify

License: Do What The F*ck You Want To Public License

JavaScript 47.48% CoffeeScript 52.52%

session-store's Introduction

Session Store

What does it do ?

This plugin will allow you to persist session variables during browser reloads and revisits using amplify.

Why?

I was expecting the meteor default Session.set('myVar', 'myVal') to act like a regular session. I was quite surprised to see that, when reloading the page, my session vars where gone. This package will expose a new api called SessionStore which inherits from Session. This means that all your session variables will still be reactive.

Usage

Installation:

meteor add smeevil:session-store

Basic usage:

You basically use this the same as you would with Session.

To store something :

SessionStore.set('myVar', 'myVal');

To retrieve something :

SessionStore.get('myVar');
# "myVal"

As an added bonus you can now inspect the store by :

SessionStore.inspect();
# {"myVar": "myVal"}

You can clear a single var using the unset method, which will return the value it contained :

SessionStore.unset('myVar');
# "myVar"

and to clear the complete store :

SessionStore.clear();
# null

Attribution:

Initial idea for this code came from sebastien.b at Stack Overflow : http://stackoverflow.com/questions/11705825/persistent-sessions-in-meteor#answer-14659117

Licensed under the WTFPL License. See the LICENSE file for details.

session-store's People

Contributors

smeevil avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.