Skip to main content

SecureCookie

@webda/core


Class: SecureCookie

Defined in: packages/core/src/session/cookie.ts:105

Object that handle the session

To get stateless server the session is encrypted inside a cookie, so you should not store large amount of data in it If you need big session then i would suggest to use a Memcache store with the user.uuid as a key

It is part of the core framework implementation, you should not rely on any method of this object, as the implementation can change if needed An object session is exposed by the framework, so use this one ( for now it is a SecureCookie.getProxy() but can evolve )

The object use Object.observe if available or try Proxy in other case, so old JS VM won't run it

You cannot store variables starting with _ in the session if you do use them they won't be persist, so it can be used to add some context

Constructors​

Constructor​

new SecureCookie(): SecureCookie

Returns​

SecureCookie

Methods​

load()​

static load(name, session, context, options?): Promise<any>

Defined in: packages/core/src/session/cookie.ts:117

Load cookie

It manages the split of the cookie to 4096 if required

Parameters​

name​

string

cookie name

session​

object

the session object

context​

IWebContext

the execution context

options?​

JWTOptions

the options

Returns​

Promise<any>

the result


save()​

static save(name, context, data, options?, cookieOptions?): Promise<void>

Defined in: packages/core/src/session/cookie.ts:160

Send a cookie, split it if required

Parameters​

name​

string

the name to use

context​

IWebContext

the execution context

data​

any

the data to process

options?​

JWTOptions

the options

cookieOptions?​

Partial<CookieOptions>

the cookie options

Returns​

Promise<void>


sendCookie()​

static sendCookie(ctx, name, value, params): void

Defined in: packages/core/src/session/cookie.ts:181

Will send the cookie to context and split it if needed as max length for cookies are 4096 including the params (the whole Set-Cookie header)

Parameters​

ctx​

IWebContext

to send cookie to

name​

string

name of the cookie

value​

string

of the cookie

params​

CookieOptions

for the cookie

Returns​

void