简体   繁体   English

如何在不同应用程序设置的Rails应用程序中读取Cookie

[英]How to read cookies in rails app set by some different application

I need to read cookies set by some different application into my rails application. 我需要将一些其他应用程序设置的cookie读入我的rails应用程序。 both the application is running under common SSO (authentication) and when the user successfully authenticated he first redirected to the first application (Node/Express app) which write some data into browser cookies and then when the user clicks on some button which loads my rails application. 应用程序都在通用SSO(身份验证)下运行,当用户成功通过身份验证时,他首先重定向到第一个应用程序(Node / Express应用程序),该应用程序将一些数据写入浏览器cookie,然后当用户单击加载我的导轨的某个按钮时应用。 it will create a rails session. 它将创建一个Rails会话。 I need to set some variables reading from the cookie set by node/express application. 我需要设置一些从node / express应用程序设置的cookie中读取的变量。

Assuming your SSO cookie is named "sso_cookie", to read the cookie: cookies[:sso_cookie] . 假设您的SSO cookie名为“ sso_cookie”,以读取cookie: cookies[:sso_cookie] To update the cookie: cookies[:sso_cookie] = 'new-value' . 更新cookie: cookies[:sso_cookie] = 'new-value'

See ActionDispatch::Cookies . 参见ActionDispatch :: Cookies

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

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