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

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

问题描述

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

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

会话使用cookies吗?

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

假设 Session [UserId] = 1 如何进行此会话变量内部使用cookie?如果是这样,那么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.

从Microsoft:

From Microsoft:


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.

http://msdn.microsoft.com/en-us/library/ms972429.aspx

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

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