从服务器端语言设置到本地存储

huangapple go评论74阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2015年2月21日 02:31:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/28635815.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定