Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public plainCookie (key: string, value: any, options?: Partial): this {
if (options) {
options = Object.assign({}, this._config.cookie, options)
} else {
options = this._config.cookie
}
const serialized = serialize(key, value, undefined, options)
if (!serialized) {
return this
}
this.append('set-cookie', serialized)
return this
}
public clearCookie (key: string, options?: Partial): this {
if (options) {
options = Object.assign({}, this._config.cookie, options)
} else {
options = this._config.cookie
}
options.expires = new Date(1)
const serialized = serialize(key, '', undefined, options)
if (!serialized) {
return this
}
this.append('set-cookie', serialized)
return this
}
public cookie (key: string, value: any, options?: Partial): this {
if (options) {
options = Object.assign({}, this._config.cookie, options)
} else {
options = this._config.cookie
}
const serialized = serialize(key, value, this._secretKey, options)
if (!serialized) {
return this
}
this.append('set-cookie', serialized)
return this
}