From 67100b45c3a3cc14740e777a698a5694632129c0 Mon Sep 17 00:00:00 2001 From: bettafish Date: Sun, 13 Jun 2021 23:50:02 +0200 Subject: [PATCH] vweb: make set_cookie also add path and domain when they're set --- vlib/vweb/vweb.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index e1498b91e2..b10ad6992a 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -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