1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vweb: add cookies with expire date

This commit is contained in:
Louis Schmieder
2020-06-29 21:14:36 +02:00
committed by GitHub
parent 7565fe595b
commit 616b07204d
3 changed files with 16 additions and 0 deletions

View File

@@ -115,6 +115,10 @@ pub fn (mut ctx Context) set_content_type(typ string) {
ctx.content_type = typ
}
pub fn (mut ctx Context) set_cookie_with_expire_date(key, val string, expire_date time.Time) {
ctx.add_header('Set-Cookie', '$key=$val; Secure; HttpOnly; expires=${expire_date.utc_string()}')
}
pub fn (ctx &Context) get_cookie(key string) ?string { // TODO refactor
mut cookie_header := ctx.get_header('cookie')
if cookie_header == '' {