Fresh pattern help

Could anyone possibly help guide me to understand the 'freshest' pattern for the following, please? When a user hits / I load a login page, and once he submits the form, the server generates some session data in the POST handler for /, and then redirects(send back a 303) to /chat. There is an island on /chat which needs to contain the session data. How would I redirect from the form POST handler, to the /chat page and make sure that my state is passed to the island? In react or similar I would handle the 'form submission' in javascript and cache the returned session data before redirecting to /chat. Since fresh seems to promote the use of native forms I'm trying to learn how I would handle this situation. I'm thinking of setting a cookie in the redirect, to then be sent with the /chat GET, which I can use to return the page with session data inside. Is that common? Thanks!
Using a cookie is probably the right thing to do.
Thanks. I'll think about that. I suppose another way would be to set the form to POST directly to /chat, and then have a POST handler there that does a ctx.render(). Not sure about the downsides to either of these yet.
of course a refresh will reset the state unless you use a cookie/localStorage
100%. Would need to persist it somehow in the island the first time the page loads. The cookie route seems cleaner in this case. Although I am trying to get my head around the possibilities because this is quite a common use case if I'm not mistaken. Submit form -> load new page with data from the the form.
do it the cookie way
thanks 👍

Looking for more? Join the community!

Recommended Posts
Deno seems to assume wrong return type (Puppeteer)With the following code, I get an type error which I do not expect: ```ts const element: ElementHanCreating my first Deno moduleHave never published to NPM or Denoland before, so I'm having some problems figuring shit out. I'm gSanitize multiple test stepsIs it possible to sanitize multiple steps inside of one test. I want to test my DB with somthing likFFI string corrupted?Is there anything i'm doing wrong here? I'm confused on why it's crashing on setVerisonUE5 in particTypescript Conditional Type ReturnsI don't know why but this conditional type return is just causing me grief. ```ts type InnerType<T>Parsing Hostname for TLD, domain name, and SLDdoes anyone know of any packages to parse a URL's hostname for the top level domain, domain name, anMigrating large Node project to DenoIs there any reliable way to migrate a Node project to Deno? Currently working on a large project thWhy does Deno.serve not return a promise anymore?Doesn't this cause problems for error handling?Changing GitHub username – what about deno.land/x?If I change my GitHub username and I have a couple of modules on deno.land/x, what will happen to thAbsolute Imports with OakI would like to have absolute imports in my Oak-API ... 😉Passing initial data to WorkerDetault `Worker` doesnt seem to support `WorkerData` as params. Although using `node:worker_threads`Adding npm specifiers to deno.jsonHow do i add a specific version of an npm module to the cache?How do I enqueue_microtask from other threadso `Isolate.enqueue_microtask` is obviously not send/sync so I think the only option is to use` std:how to import svg in vite without type errors?