简体   繁体   English

如何从rails gem读取应用程序的cookie

[英]How to read cookies of an application from a rails gem

I wrote a gem which will read the cookies of an application that installs my gem. 我写了一个gem,它将读取安装我的gem的应用程序的cookie。 But, I am not able to do that because when I try to add the line cookies[:name] , it is throwing the exception undefined method "cookies" . 但是,我无法做到这一点,因为当我尝试添加行cookies[:name] ,它会抛出异常undefined method "cookies"

How to achieve this? 怎么做到这一点? Your help is appreciated. 非常感谢您的帮助。

First of all, applications don't store cookies, only browsers do. 首先,应用程序不存储cookie,只有浏览器存储。 That said, you can access those cookies from your controllers. 也就是说,您可以从控制器访问这些cookie。 See the documentation on cookies here: http://guides.rubyonrails.org/action_controller_overview.html#cookies 请参阅有关cookie的文档: http//guides.rubyonrails.org/action_controller_overview.html#cookies

Your question is kind of vague. 你的问题有点模糊。 You might have to share some code to get a quality answer. 您可能需要共享一些代码才能获得高质量的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM