仅使用Javascript会话Cookie [英] Session only cookies with Javascript
问题描述
我想知道是否可以使用Javascript创建仅会话cookie。浏览器关闭时,Cookie应该被删除。
我不能在服务器上使用任何东西,因为网站只有HTML,所以没有使用服务器端脚本。
我在这里阅读了一些有关这方面的内容:
http://blog.lysender.com/2011/08/setting-session-only-cookie-via-javascript/
但我找不到更多有关此信息...所以我想知道这个方法是否可靠。
是的,这是正确的。
不管是 expires
部分都会创建一个会话cookie,无论它是在JavaScript中还是在服务器上创建。
请参阅 https://stackoverflow.com/a/532660/1901857 p>
I was wondering if it's possible to create session only cookies with Javascript. When the browser is closed the cookies should be removed.
I can't use anything on the server as the website is HTML only ... so no server side script is used.
I read something about this here: http://blog.lysender.com/2011/08/setting-session-only-cookie-via-javascript/ but i can't find any more information about this ... so i was wondering if this method is reliable.
Yes, that is correct.
Not putting an expires
part in will create a session cookie, whether it is created in JavaScript or on the server.
See https://stackoverflow.com/a/532660/1901857
这篇关于仅使用Javascript会话Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!