vweb: make set_cookie also add path and domain when they're set

pull/10450/head
bettafish 2021-06-13 23:50:02 +02:00
parent 90fea290ba
commit 67100b45c3
1 changed files with 6 additions and 0 deletions

View File

@ -218,6 +218,12 @@ pub fn (mut ctx Context) enable_chunked_transfer(max_chunk_len int) {
// Sets a cookie
pub fn (mut ctx Context) set_cookie(cookie Cookie) {
mut cookie_data := []string{}
if path := cookie.path {
cookie_data << 'path=$path;'
}
if domain := cookie.domain {
cookie_data << 'domain=$domain;'
}
mut secure := if cookie.secure { 'Secure;' } else { '' }
secure += if cookie.http_only { ' HttpOnly' } else { ' ' }
cookie_data << secure