Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set to localStorage from a server side language

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)
like image 735
BrainLikeADullPencil Avatar asked Feb 20 '15 18:02

BrainLikeADullPencil


People also ask

Can you access localStorage from server side?

As you mentioned localStorage and sessionStorage are not available on the server. You could use cookie and access them inside getServerSideProps via req. cookies .

Can local storage server be set?

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.


1 Answers

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.

like image 196
Gaurang Patel Avatar answered Oct 14 '22 16:10

Gaurang Patel