fix(web): cookie auto expires

This commit is contained in:
əlemi 2024-04-18 03:52:16 +02:00
parent 0b4b4e7cce
commit 179fd0807b
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -2,12 +2,18 @@ use leptos::*;
use leptos_router::*; use leptos_router::*;
use crate::prelude::*; use crate::prelude::*;
use leptos_use::{use_cookie, utils::FromToStringCodec}; use leptos_use::{use_cookie, use_cookie_with_options, utils::FromToStringCodec, UseCookieOptions};
#[component] #[component]
pub fn App() -> impl IntoView { pub fn App() -> impl IntoView {
let (auth, set_auth) = use_cookie::<String, FromToStringCodec>("token"); let (auth, set_auth) = use_cookie_with_options::<String, FromToStringCodec>(
"token",
UseCookieOptions::default()
.max_age(1000 * 60 * 60 * 6)
.readonly(false)
.domain(URL_BASE)
);
let (username, set_username) = use_cookie::<String, FromToStringCodec>("username"); let (username, set_username) = use_cookie::<String, FromToStringCodec>("username");
provide_context(auth); provide_context(auth);