• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

跟踪"谈话"流入西纳特拉

用户头像
it1352
帮助1

问题说明

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.

正确答案

#1

我想你混淆了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
系列文章
更多 icon
同类精品
更多 icon
继续加载