27 lines
1.0 KiB
Go
27 lines
1.0 KiB
Go
// Package cookies provides utilities for handling HTTP cookies in Go web applications.
|
|
// It includes functions for setting secure cookies, deleting cookies, and managing
|
|
// pagefrom tracking for post-login redirects.
|
|
//
|
|
// The package follows security best practices by setting the HttpOnly flag on all
|
|
// cookies to prevent XSS attacks. The SetCookie function allows you to specify the
|
|
// name, path, value, and max-age for cookies.
|
|
//
|
|
// The pagefrom functionality helps with user experience by remembering where a user
|
|
// was before being redirected to login/register pages, then redirecting them back
|
|
// after successful authentication.
|
|
//
|
|
// Example usage:
|
|
//
|
|
// // Set a session cookie
|
|
// cookies.SetCookie(w, "session", "/", "abc123", 3600)
|
|
//
|
|
// // Delete a cookie
|
|
// cookies.DeleteCookie(w, "old_session", "/")
|
|
//
|
|
// // Handle pagefrom tracking
|
|
// cookies.SetPageFrom(w, r, "example.com")
|
|
// redirectTo := cookies.CheckPageFrom(w, r)
|
|
//
|
|
// All functions are designed to be safe and handle edge cases gracefully.
|
|
package cookies
|