Vue Auth / Guides / Cookies

The cookie option specifies parameters to store with the cookie. It contains a key / value pairing with the key being the parameter name and the value being set accordingly based on a few simple rules described below.

This only applies when using the cookie storage option.

With this setup there are some default minimum values for the cookies. But any others can be added or removed by extending or overriding this parameter.


By default the cookie will simply set the key to the value as in Key=Val;. The few exceptions are listed below for special case values.

false || undefined

In this case it will be skipped and is the same as not including it at all.


In this case it will simply set the key with no equals value. For instance, when setting Secure; on the cookie which does not require a value.


The null value is meant for dynamic cases, as with the Domain value which dynamically gets the current domain. In this case if the value is null it will attempt to find an option in the format getCookie:Key. So in the case of Domain it would look for options.getCookieDomain.

This allows the cookie parameters to be extended with any other dynamic functions as needed.

Expires Key

There is one special built in case with the cookie.Expires value. The correct value for this is a date string. However, there is a built in check for a non string integer offset value that will automatically convert to a date. This is to simplify things with a simple offset.


We can take a look at some of the current default values:

cookie: {
    Path:     '/',
    Domain:   null,
    Secure:   true,
    Expires:  12096e5,
    SameSite: 'None',

If the set cookie function is run with a key/value of "myval" and "blah" the resulting cookie would look something like the following.

myval=blah; Path=/;; Secure; Expires=Sat, 11 Apr 2020 02:50:26 GMT; SameSite=None;

In the above example, the domain was dynamically returned from the getCookieDomain function and the Expires was automatically converted to a date string for us.

Any other parameters added there would follow the same pattern.