If it's possible to set a cookie from a server side language, is it possible for a server side language to store data in the localStorage property of a browser? I'm interested in doing it in Go but I suppose the principle would be the same in any language. Go has a SetCookie
to set a Cookie but not a function to set localStorage. Is there a way to implement it?
http.SetCookie(w, cookie)
As you mentioned localStorage and sessionStorage are not available on the server. You could use cookie and access them inside getServerSideProps via req. cookies .
It's not possible to set it from the server side code as you do with cookies using Set-Cookie response header. More information on localStorage.
localStorate
is meant for reading/writing on the client side only. It's not possible to set it from the server side code as you do with cookies using Set-Cookie
response header. More information on localStorage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With