我是 Web 开发中使用 cookie 的新手。
我可以用JavaScript或Ruby on Rails编写cookie,指定特定的路径,如下所示:
在 JavaScript 中
document.cookie = 'some_key=123;path=/foo/bars'
在轨道中
cookies[:some_key] = { value: 123, path: '/foo/bars' }
另一方面,我找不到如何在某个路径中读取cookie,无论是在JavaScript还是Rails中。
有没有办法做到这一点?
由于安全原因,您无法看到其他网站的 Cookie。 您只能访问您的网站设置的 Cookie。您可以看到的所有 cookie 都在 document.cookie 属性中。