跟踪"谈话"流入西纳特拉
问题说明
Consider this post. I'm dealing with messaging API, however it's not the Twilio API. The server in question has no explicit support for storing cookies so I'm wondering how I can store the session state/data either in memory, on my server or in a database somehow.
时的那样简单使用机架::会议::游泳池
作为cookie的方法是什么?我找不到任何好的TUTS或例子。
Is it as simple as using Rack::Session::Pool
as the cookie method? I can't find any good tuts or examples.
正确答案
我想你混淆了cookie和会话了一下。
I think you mix up cookies and sessions a bit.
饼干
一个cookie,也被称为一个HTTP cookie,网络Cookie或浏览器cookie,是一小片从一个网站发送并存储在用户的Web浏览器,而用户浏览该网站的数据。 源
A cookie, also known as an HTTP cookie, web cookie, or browser cookie, is a small piece of data sent from a website and stored in a user's web browser while the user is browsing that website. source
This mean there are small text files on client site with information in it. This mean it's maybe not the best idea to save sensitive content in clear text. And you must be aware, that it's in client hand if it accept cookies.
在西纳特拉它们都建在,但命名会话(我知道,有点混乱,这是因为cookie是客户端Web会话)
In sinatra they are built in but named session (I know, a bit confusing, this is because cookies are Client side web sessions)
举例code
require 'sinatra'
enable :sessions
get '/' do
session["value"] ||= "Hello world!"
"The cookie you've created contains the value: #{session["value"]}"
end
和有西纳特拉::在西纳特拉的Contrib 饼干。我不知道为什么这甚至存在,但值得一提的。
And there is Sinatra::Cookies in Sinatra Contrib. I have no clue why this even exist, but it worth mentioning.
会议
会话或显式服务器端Web会话是为每个客户端是坚持服务器站点的状态。
Sessions or explicit Server side web sessions is a state for each client which is hold on server site.
举例code
require 'sinatra'
use Rack::Session::Pool
get '/' do
session["value"] ||= "Hello world!"
"The server side session you've created contains the value: #{session["value"]}"
end
结论和放大器; TL; DR
不知道什么你到底努力实现,这是很难说这会为你工作好。此外,甚至有可能对两个组合和状态保存到数据库。因此,它取决于你试图达到的目标。
Without knowing what you exactly try to achieve, it's hard to tell which will work better for you. Additionally there is even possible to combine both and save the state to a Database. So it depend on what you try to achieve.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfgijj
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20