Skip to main content

@webda/coreReadme | API


Class: SecureCookie

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

new SecureCookie()

new SecureCookie(): SecureCookie

Returns

SecureCookie

Methods

load()

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

Load cookie

It manages the split of the cookie to 4096 if required

Parameters

name: string

cookie name

context: WebContext<any, any>

options?: JWTOptions

Returns

Promise<any>

Source

packages/core/src/utils/cookie.ts:98


save()

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

Send a cookie, split it if required

Parameters

name: string

context: WebContext<any, any>

data: any

options?: JWTOptions

cookieOptions?: Partial<CookieOptions>

Returns

Promise<void>

Source

packages/core/src/utils/cookie.ts:141


sendCookie()

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

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: WebContext<any, any>

to send cookie to

name: string

name of the cookie

value: string

of the cookie

params: CookieOptions

for the cookie

Returns

void

Source

packages/core/src/utils/cookie.ts:162