Skip to content
This repository was archived by the owner on Oct 7, 2018. It is now read-only.

Latest commit

 

History

History
24 lines (17 loc) · 646 Bytes

sessions.md

File metadata and controls

24 lines (17 loc) · 646 Bytes

Sessions

Since HTTP driven applications are stateless, sessions provide a way to store information about the user across requests.

Strapi provides "guest" sessions, meaning any visitor will have a session, authenticated or not. If a session is new a Set-Cookie will be produced regardless of populating the session.

Strapi only supports cookie sessions, for now.

The current session is available in this.session inside a controller action.

let count = this.session.views || 0;
this.session.views = ++count;
this.body = count + ' views';

To destroy an active session, simply set it to null:

this.session = null;