import CookieStore from 'ember-simple-auth/session-stores/cookie';

Session store that persists data in a cookie.

By default the cookie session store uses a session cookie that expires and is deleted when the browser is closed. The cookie expiration period can be configured by setting the cookieExpirationTime property. This can be used to implement "remember me" functionality that will either store the session persistently or in a session cookie depending on whether the user opted in or not:

// app/controllers/login.js
          export default Ember.Controller.extend({
            rememberMe: false,
          
            _rememberMeChanged: Ember.observer('rememberMe', function() {
              const expirationTime = this.get('rememberMe') ? (14 * 24 * 60 * 60) : null;
              this.set('session.store.cookieExpirationTime', expirationTime);
            }
          });
          

Applications that use FastBoot must use this session store by defining the application session store like this:

// app/session-stores/application.js
          import CookieStore from 'ember-simple-auth/session-stores/cookie';
          
          export default CookieStore.extend();
          

Methods

source public

clear( ) Ember.RSVP.Promise

Overrides: clear of BaseStore.

Clears the store by deleting the cookie.

Returns

Ember.RSVP.Promise

A promise that resolves when the store has been cleared successfully and rejects otherwise.

source public

persist(data) Ember.RSVP.Promise

Overrides: persist of BaseStore.

Persists the data in the cookie.

Arguments

data: Object

The data to persist

Returns

Ember.RSVP.Promise

A promise that resolves when the data has successfully been persisted and rejects otherwise.

source public

restore( ) Ember.RSVP.Promise

Overrides: restore of BaseStore.

Returns all data currently stored in the cookie as a plain object.

Returns

Ember.RSVP.Promise

A promise that resolves with the data currently persisted in the store when the data has been restored successfully and rejects otherwise.

Properties

source public

cookieDomain: String

Default: null

The domain to use for the cookie, e.g., "example.com", ".example.com" (which includes all subdomains) or "subdomain.example.com". If not explicitly set, the cookie domain defaults to the domain the session was authenticated on.

source public

cookieExpirationTime: Integer

Default: null

The expiration time for the cookie in seconds. A value of null will make the cookie a session cookie that expires and gets deleted when the browser is closed.

The recommended minimum value is 90 seconds. If your value is less than that, the cookie may expire before its expiration time is extended (expiration time is extended every 60 seconds).

source public

cookieName: String

Default: ember_simple_auth-session

The name of the cookie.

Events

source

sessionDataUpdated

Inherited from: sessionDataUpdated of BaseStore.

Triggered when the session store's data changes due to an external event, e.g., from another tab or window of the same application. The session handles that event, passes the updated data to its authenticator's restore method and handles the result of that invocation accordingly.

Arguments

data: Object

The updated session data