Skip to main content

cookie

Function cookie 

Source
pub fn cookie(name: &str) -> Result<Option<String>, CfError>
Expand description

Read a named cookie from the incoming request’s Cookie header.

Returns Ok(None) if the cookie is not present.

§Errors

Returns CfError if the Cookie header cannot be read.

§Example

use dioxus_cloudflare::prelude::*;

#[server]
pub async fn who_am_i() -> Result<String, ServerFnError> {
    let session = cf::cookie("session")?.unwrap_or_default();
    Ok(session)
}