Skip to content

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

@mamcx

Description

@mamcx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions