Skip to content

Commit

Permalink
Merge branch 'master' into bowen/#450
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbrzzl authored Jul 3, 2024
2 parents 168c398 + 014b541 commit 311f5b7
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 606 deletions.
7 changes: 6 additions & 1 deletion context_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"

"github.com/gin-gonic/gin"

contractshttp "github.com/goravel/framework/contracts/http"
"github.com/goravel/framework/support/carbon"
)

type ContextResponse struct {
Expand All @@ -19,6 +19,11 @@ func NewContextResponse(instance *gin.Context, origin contractshttp.ResponseOrig
}

func (r *ContextResponse) Cookie(cookie contractshttp.Cookie) contractshttp.ContextResponse {
if cookie.MaxAge == 0 {
if !cookie.Expires.IsZero() {
cookie.MaxAge = int(cookie.Expires.Sub(carbon.Now().StdTime()).Seconds())
}
}
r.instance.SetCookie(cookie.Name, cookie.Value, cookie.MaxAge, cookie.Path, cookie.Domain, cookie.Secure, cookie.HttpOnly)

return r
Expand Down
Loading

0 comments on commit 311f5b7

Please sign in to comment.