Skip to content

Setting a cookie server side with use_cookie doesn't set anything #231

@steadygaze

Description

@steadygaze

Hello, thanks for creating all these helpers! I've been wondering if I've been doing something horribly wrong, but the use_cookie helper doesn't seem to actually be able to set cookies in server functions. Meanwhile, it is possible to set cookies in server functions using leptos_actix. I gave the source code a cursory look, and that seems to be what it's doing, so I'm not sure what's going wrong.

I've created a minimal example demonstrating this: steadygaze/start-actix-use-cookie-repro@b45e30d

So, there is this note in the Leptos-Use site

This works equally well on the server or the client. On the server this function reads the cookie from the HTTP request header and writes it back into the HTTP response header according to options (if provided). The returned WriteSignal may not affect the cookie headers on the server! It will try and write the headers buy if this happens after the headers have already been streamed to the client then this will have no effect.

but I don't think streaming is coming into play if leptos_actix is able to set the headers still.


Secondarily, cookies updated on the server won't update in SSR, but the docs already note this. Is there a way to say "ok, recheck the cookies now because I think they might've changed"? (For context, this is the general thing I'm trying to do: leptos-rs/leptos#3609.)

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