如何在Rails应用程序中获取持久性cookie值和会话cookie值 [英] how to get the persistent cookie value and session cookie value in rails application

查看:116
本文介绍了如何在Rails应用程序中获取持久性cookie值和会话cookie值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Rails应用程序中的红宝石.我想在应用程序中获取持久性cookie值和会话cookie值.有什么可以指导我的吗

Im developing ruby on rails application. I want to get the persistent cookie value and session cookie value in the application. Can any please guide me on this

我已经阅读到request.session_options [:id]将获取session_id,这是通常存储在会话cookie中的那个吗?如果我的理解方式有误,请指导我.谢谢!

I have read that request.session_options[:id] will fetch the session_id, is that the one that is usually stored in session cookie? Please guide me if my way of understanding is wrong.Thanks in advance

推荐答案

在Rails中,调用会话或cookie哈希很简单.

In Rails, it is simple as calling the session or cookies hash.

# Set a simple session cookie
cookies[:user_name] = "david" 
# Read a cookie 
cookies[:user_name]  # => "david"
# Delete a key
cookies.delete :user_name

会话也是如此.因此,您正在寻找的信息可能在这两个信息之一之内.

The same goes for session. So, the information that you are looking for is probably inside one of these two.

http://www上查看示例.tutorialspoint.com/ruby​​-on-rails/rails-session-cookies.htm

这篇关于如何在Rails应用程序中获取持久性cookie值和会话cookie值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆