Skip to content

tedshd/cookie_control

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

cookie_control

cookie control

set cookie or update cookie or delete cookie

cookieControl(<method>, <option>);

Method(String)

  • get
    • get this cookie
  • set
    • set this cookie value
  • delete
    • delete this cookie

Option(Object)

cookie_control

key type required description example
name string yes cookie name 'cookie_name'
value string yes cookie value 'hello'
expiredTime number no cookie expired time & unit is seconds 60
domain string no cookie's domain 'example.com'
path string no cookie's path '/'

Notice:

if expiredTime is empty, this cookie is session cookies.

Example

var opt = {
    name: 'test',
    value: '123321',
    expiredTime: 5*60
};

cookieControl('set', opt);

cookieControl('get', {
    name: 'test'
});

Reference