vue-sessionstorage

A Simple Plugin to Deal with SessionStorage on Vue.js
31,837 8
Install
npm install vue-sessionstorage
Latest Version:1.0.0
License:ISC
Last Updated:Aug 11, 2017
Links: GitHub  ·  npm
Maintainer: wac2007

Vue SessionStorage

A Simple Plugin to Deal with SessionStorage on Vue.js

This plugin is ready to work with Unit Tests mocking the sessionStorage.

Install

npm install --save vue-sessionstorage

Put in your main.js

import VueSessionStorage from 'vue-sessionstorage'
Vue.use(VueSessionStorage)

Docs

this.$session.get(key)

Get a value previously saved

this.$session.set(key, value)

Set a value in current session

this.$session.exists(key)

Check if the current key exists in current session

this.$session.remove(key)

Remove the chosen key from session

this.$session.clear(key)

Clear all the current sessions

Example

Let's suppose you are building a login system

export default {
    name: 'login',
    methods: {
        doLogin() {
            axios.post('/login', {...}).then(response => {
                let username = response.data.username;
                this.$session.set('username', username); // Set the username in session Storage
            });
        }
    } 
    
}

Related Packages

vue-web-storage

Vue.js plugin for localStorage and sessionStorage

74,878 83
vue-storage-decorator

Give a Persist decorator to persist vue object properties to some storage

1,334 1
@mudas/storage

This is a tool library that supports session Storage, local Storage, cookie, map...

883 1
vue-easysession

A manage easy session storage plugin for VueJS

745 7
vue2-storage

Browser storage for JavaScript or Vue.js app

60,790 109

Version History

Version Released License
1.0.0 ISC