做会话使用cookies? [英] Do session use cookies?

查看:159
本文介绍了做会话使用cookies?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个面试问题问一个月前....

This is an interview question asked a month ago....

做会话使用cookies?如果是这样,他们怎么做呢?

Do session use cookies? If so,how do they do so?

假设会话[用户ID] = 1 请问这个会话变量使用cookies内部?如果是的话,会是怎样的cookie的名称,什么是cookie的值......

Assume Session["UserId"]=1 how does this session variable uses cookies internally? If so, what will be the name of the cookie and what is the value of that cookie....

推荐答案

虽然自身被存储在服务器上(或在SQL如果配置这样)中的数据,需要有与特定用户会话数据相关联的方法

Whilst the data its self is stored on the server (or in SQL if configured that way), there needs to be a way to associate session data with specific users.

默认情况下它是用饼干做的,但您可以配置在这种情况下,唯一的ID被存储在URL中Cookie的。

By default this is done with a cookie, but you can configure cookieless in which case the unique id is stored in the URL.

从微软:

ASP通过提供客户端,与会话开始时分配给该用户的唯一密钥保持会话状态。这个密钥存储在客户端发送到每个请求的服务器的HTTP Cookie中。然后,服务器可以从cookie读取密钥并重新膨胀服务器会话状态。

ASP maintains session state by providing the client with a unique key assigned to the user when the session begins. This key is stored in an HTTP cookie that the client sends to the server on each request. The server can then read the key from the cookie and re-inflate the server session state.

<一个href=\"http://msdn.microsoft.com/en-us/library/ms972429.aspx\">http://msdn.microsoft.com/en-us/library/ms972429.aspx

这篇关于做会话使用cookies?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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