cookieManager.js 651 Bytes
/**
 * Created by shipfi on 2016/9/23.
 */
import cookie from 'react-cookie';
import { CookieDomain} from '../config';

let cookieConfig = {};
if(CookieDomain) {
    cookieConfig = { domain : CookieDomain };
}

export default {
    saveCookie: function(name,value) {
        cookie.save(name,value,cookieConfig);
    },
    
    getCookie : function(name) {
        return cookie.load(name);
    },
    
    removeCookie : function(name) {
        cookie.remove(name,cookieConfig);
    },
    
    signOut : function() {
        cookie.remove('token',cookieConfig);
    },
    
    isLogin : function(){
        return !!cookie.load('token');
    }
}