Sessions broken on external hosts ?
Hi, I'm making a web-based game and I use the sessions to store the player's information (but most importantly the player ID) which I then use in various async
query
s to display the user's score and name for example.
The session is created by the user first being prompted to choose a name, which is then sent to the server with an actions. If successful, the player object is returned and all query
s are invalidated so that the page transitions from "must create name first" phase to "can now play" phase.
This has been working great both in dev and production modes for now. But after deploying to the remote test host it is now impossible to get past the "Please choose a name" screen. This only occurs with hosts other than localhost, meaning that if I open the web page on the server, it works fine. But if I open from another computer on the network, the aforementioned issue occurs.
Looking at the Network tab of firefox I see two _server
requests (which are the two query
s used on the page, so it's normal. But the problems starts when looking at the response cookies. When on local host we can see a set-cookie
in the response header. But when connection from a different host, we can see two set-cookie
(See images). Which I guess means one of them gets overridden and most probably by a cookie not containing the correct session data.
Has anyone experienced that ? I'm not sure ifit's an issue I can solve since it looks like its a weird behavior from vinxi's session handler.8 Replies
this does fit in an issue
My assumptions were wrong. It's because of the "Secure" attribute of the cookie.
multiple
set-cookie
-s are valid
but they both use the same keyYes yes. I guess I need to find a way to build for HTTP and not HTTPS
i'm not sure i follow
this means the latter would override the the former as you've assumed
Well it works now
¯\_(ツ)_/¯
For future reference: an option can be passed to disable secure mode
I need this because my app will be run locally on closed network.
ah, you meant that by this
sorry you went through all this hunt.
For what it's worth, sessions in SolidStart are handled by H3
https://h3.unjs.io/examples/handle-session
our
useSession
is just a re-export from the h3 package.
The way it goes is:
h3 is used by Nitro
Nitro is used by Vinxi
Vinxi is used by SolidStartHandle Session - h3
Remember your users using a session.