服务器如何知道哪个会话属于哪个客户端?

时间:2022-03-31 02:53:19

In my office we have multiple computers and when we check from a remote server what is the IP of each computer, since they all come out of the same router, I get the same IP.

在我的办公室,我们有多台计算机,当我们从远程服务器检查每台计算机的IP是什么时,因为它们都来自同一台路由器,所以我得到了相同的IP。

This started me thinking about how the server knows what session belongs to which client? What identifies one computer from another in the eyes of the server when the IP address is similar?

这开始让我思考服务器如何知道哪个会话属于哪个客户端?当IP地址相似时,服务器眼中的另一台计算机是什么?

Thanks everyone!

感谢大家!

2 个解决方案

#1


2  

Server sends a cookie to the user with a session id. This session id identifies the user to the server. ASP.NET can also append the session id to the query string if cookies are turned off.

服务器使用会话ID向用户发送cookie。此会话标识标识服务器的用户。如果关闭cookie,ASP.NET还可以将会话ID附加到查询字符串。

http://msdn.microsoft.com/en-us/magazine/cc163730.aspx

http://msdn.microsoft.com/en-us/magazine/cc163730.aspx

#2


0  

On each request made to server by the client a TCP connection is made with has common IP address in your case but different port and each client is differentiated on the bases of port to send the response back to the client. You can read more about TCP connections over here.

在客户端向服务器发出的每个请求中,TCP连接都是在您的情况下具有公共IP地址,但不同的端口和每个客户端在端口的基础上进行区分,以将响应发送回客户端。您可以在此处阅读有关TCP连接的更多信息。

If you are talking about HTTP session then they use cookies / query string in url to identifiy session, you can read more over here.

如果您正在谈论HTTP会话,那么他们在URL中使用cookie /查询字符串来识别会话,您可以在这里阅读更多内容。

Session Identifiers

会话标识符

Sessions are identified by a unique identifier that can be read by using the SessionID property. When session state is enabled for an ASP.NET application, each request for a page in the application is examined for a SessionID value sent from the browser. If no SessionID value is supplied, ASP.NET starts a new session and the SessionID value for that session is sent to the browser with the response. By default, SessionID values are stored in a cookie. However, you can also configure the application to store SessionID values in the URL for a "cookieless" session, reference.

会话由唯一标识符标识,可以使用SessionID属性读取。为ASP.NET应用程序启用会话状态时,将检查应用程序中页面的每个请求,以查找从浏览器发送的SessionID值。如果未提供SessionID值,ASP.NET将启动一个新会话,并将该会话的SessionID值发送到带有响应的浏览器。默认情况下,SessionID值存储在cookie中。但是,您还可以将应用程序配置为在URL中存储SessionID值,以用于“无cookie”会话,引用。

#1


2  

Server sends a cookie to the user with a session id. This session id identifies the user to the server. ASP.NET can also append the session id to the query string if cookies are turned off.

服务器使用会话ID向用户发送cookie。此会话标识标识服务器的用户。如果关闭cookie,ASP.NET还可以将会话ID附加到查询字符串。

http://msdn.microsoft.com/en-us/magazine/cc163730.aspx

http://msdn.microsoft.com/en-us/magazine/cc163730.aspx

#2


0  

On each request made to server by the client a TCP connection is made with has common IP address in your case but different port and each client is differentiated on the bases of port to send the response back to the client. You can read more about TCP connections over here.

在客户端向服务器发出的每个请求中,TCP连接都是在您的情况下具有公共IP地址,但不同的端口和每个客户端在端口的基础上进行区分,以将响应发送回客户端。您可以在此处阅读有关TCP连接的更多信息。

If you are talking about HTTP session then they use cookies / query string in url to identifiy session, you can read more over here.

如果您正在谈论HTTP会话,那么他们在URL中使用cookie /查询字符串来识别会话,您可以在这里阅读更多内容。

Session Identifiers

会话标识符

Sessions are identified by a unique identifier that can be read by using the SessionID property. When session state is enabled for an ASP.NET application, each request for a page in the application is examined for a SessionID value sent from the browser. If no SessionID value is supplied, ASP.NET starts a new session and the SessionID value for that session is sent to the browser with the response. By default, SessionID values are stored in a cookie. However, you can also configure the application to store SessionID values in the URL for a "cookieless" session, reference.

会话由唯一标识符标识,可以使用SessionID属性读取。为ASP.NET应用程序启用会话状态时,将检查应用程序中页面的每个请求,以查找从浏览器发送的SessionID值。如果未提供SessionID值,ASP.NET将启动一个新会话,并将该会话的SessionID值发送到带有响应的浏览器。默认情况下,SessionID值存储在cookie中。但是,您还可以将应用程序配置为在URL中存储SessionID值,以用于“无cookie”会话,引用。