Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How have 2 different cookies/sessions for both '/' and '/admin'? #475

Open
mamcx opened this issue Oct 24, 2024 · 0 comments
Open

How have 2 different cookies/sessions for both '/' and '/admin'? #475

mamcx opened this issue Oct 24, 2024 · 0 comments

Comments

@mamcx
Copy link

mamcx commented Oct 24, 2024

How can I have different cookies for different parts of a site?

The root:/ is for a public-facing site that log regular users, and '/admin' is only for employees.

I tried:

       App::new()
..
            .wrap(
                IdentityMiddleware::builder()
                    .id_key("bestseller.user_id")
                    .last_visit_unix_timestamp_key("bestseller.last_visit")
                    .login_unix_timestamp_key("bestseller.login")
                    .build(),
            )
            .wrap(
                SessionMiddleware::builder(CookieSessionStore::default(), Key::from(&[123; 64]))
                    .cookie_name("bestseller_session".into())
                    .build(),
            )
            .wrap(TracingLogger::default()) //always last
            .service(fs::Files::new("/static", static_path()))
            .configure(api)
            .configure(back_end)
            .configure(back_end2)
            //Public
            .wrap(
                IdentityMiddleware::builder()
                    .id_key("bestseller_store.user_id")
                    .last_visit_unix_timestamp_key("bestseller_store.last_visit")
                    .login_unix_timestamp_key("bestseller_store.login")
                    .build(),
            )
            .wrap(
                SessionMiddleware::builder(CookieSessionStore::default(), Key::from(&[123; 64]))
                    .cookie_name("bestseller_store".into())
                    .build(),
            )
            .configure(front_end)
    });

But I only see the first cookie stored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant