英文:
set to localStorage from a server side language
问题
如果可以使用服务器端语言设置cookie,那么服务器端语言是否可以将数据存储在浏览器的localStorage属性中?我对在Go语言中实现此功能感兴趣,但我想原理在任何语言中应该是相同的。Go语言有一个SetCookie
函数用于设置Cookie,但没有设置localStorage的函数。有没有一种实现它的方法?
http.SetCookie(w, cookie)
英文:
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)
答案1
得分: 11
localStorage
仅用于在客户端读取/写入数据。无法像使用 Set-Cookie
响应头设置 cookie 一样,从服务器端代码设置它。有关更多信息,请参阅 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论