package infra

import (
	"net/http"
	"time"
)

// SessionCookieSet writes a session cookie to the response.
// The cookie is HttpOnly, Path="/", SameSite=Lax and expires at the
// Unix timestamp expiresAt (seconds). It does not return an error
// because http.SetCookie never fails at runtime.
func SessionCookieSet(w http.ResponseWriter, name, token string, expiresAt int64) {
	http.SetCookie(w, &http.Cookie{
		Name:     name,
		Value:    token,
		Path:     "/",
		HttpOnly: true,
		SameSite: http.SameSiteLaxMode,
		Expires:  time.Unix(expiresAt, 0),
	})
}
