rusty-cookie

Crates.iorusty-cookie
lib.rsrusty-cookie
version0.1.2
sourcesrc
created_at2024-11-28 13:12:21.468298
updated_at2024-11-28 13:14:47.521808
descriptionrusty_cookie is a Rust crate that provides a simple and flexible way to create, manage, and handle cookies with various configuration options. This crate offers attributes such as `SameSite`, `Secure`, `HttpOnly`, and more to ensure cookies are configured properly for privacy and security
homepagehttps://crates.io/crates/rusty_cookie
repositoryhttps://github.com/HashiramaSenjuhari/rusty-cookie
max_upload_size
id1464341
size15,522
Hariprasath (HashiramaSenjuhari)

documentation

https://docs.rs/rusty_cookie/latest/rusty_cookie/

README

Rusty Cookie Crate

rusty_cookie is a Rust crate that provides a simple and flexible way to create, manage, and handle cookies with various configuration options. This crate offers attributes such as SameSite, Secure, HttpOnly, and more to ensure cookies are configured properly for privacy and security.

Features

  • Secure Cookies: Ensures cookies are sent over HTTPS.
  • HttpOnly Cookies: Protects cookies from client-side JavaScript access.
  • SameSite Policy: Controls whether cookies are sent with cross-site requests.
  • Expiration and Max-Age: Allows you to set expiration times for cookies.
  • Path-based Cookies: Assign cookies to specific URL paths.
  • Custom Cookie Properties: You can specify different properties for cookies, such as security level.

Installation

To use rusty_cookie in your project, add the following dependency in your Cargo.toml:


  [dependencies]
  rusty_cookie = "0.1.2"


    use rusty_cookie::Cookie;

    fn main() {
        let cookie = Cookie::new()
            .key("secure_code")                          // The key (name) of the cookie
            .value("rt8uygyiuiouhopijuhu8yu8ui")         // The value of the cookie
            .http_only(true)                             // Make the cookie HttpOnly (cannot be accessed via JavaScript)
            .same_site(SameSite::Lax)                    // Set the SameSite policy (Lax, Strict, None)
            .max_age(3600)                               // Set the cookie's Max-Age (in seconds)
            .path("/")                                   // Set the cookie's path to root
            .properties(Properties::High)                // Set cookie's properties (Low, Medium, High)
            .secure(true)                                // Mark the cookie as secure (sent only over HTTPS)
            .build();                                    // Build the cookie
    }


  Set-Cookie: secure_code=rt8uygyiuiouhopijuhu8yu8ui; HttpOnly; SameSite=Lax; Secure; Path=/; Max-Age=3600; Priority=High;

Commit count: 0

cargo fmt