use axum::http::{HeaderValue, header};
use axum::response::{IntoResponse, Redirect, Response};
pub fn session_cookie_redirect(
access_token: &str,
destination: &str,
max_age_secs: i64,
) -> Response {
let cookie = format!(
"access_token={access_token}; Path=/; HttpOnly; Secure; SameSite=Lax; \
Max-Age={max_age_secs}"
);
let mut response = Redirect::to(destination).into_response();
if let Ok(cookie_value) = HeaderValue::from_str(&cookie) {
response
.headers_mut()
.append(header::SET_COOKIE, cookie_value);
}
response
}