Where is session stored if cookie is disabled on client's machine? What is actually stored in session?

主宰稳场 提交于 2020-01-23 07:00:08

问题


In config file I have the below settings

sessionState mode="InProc" cookieless="false"

Does this indicates that the sessionid is stroed in cookies? If yes then how is it picked and sent to the server and how is it verified across postbacks.

What will happen if cookies are disabled in my browser, will the session(sessionid and session variables) still be created?

Where(default path) are the cookies created and stored by default for sessions and can i change the path?

What format and kind of data is stored in cookies for session?

If i store a class object in session then what is actually stored in cookies?

Also if i use authentication mode as forms with cookies then what will happen if cookies are disabled in browser?


回答1:


The session cookie is a special non-persistant cookie. It's only stored in memory, so in most cases even when cookies are disabled it still works fine.

It's also possible to enable something called cookieless sesssions where the sessionID is embedded in the URL, like this:

http://yourserver/folder/ (encrypted session ID here) /default.aspx

Here's a link to an MSDN article with more details: http://msdn.microsoft.com/en-us/library/aa479314.aspx

NOTE: It is possible to completely block the session cookie. For instance, in IE8, I just went into Tools > Internet Options > Privacy. When I cranked the slider up to 'High' or greater, my sites never got past the login screen because the session cookie was blocked - in fact, Josh Stodola said below that in this case the session would never even be created on the server.

However, understand that this type of behavior effectively breaks the Internet. So unless you're building a site targeted at conspiracy theorists, in my opinion (and the opinion of most of the largest sites in the world) there's no need to cater to the tiny percentage of users who don't play by the normal rules.

For them, the Internet just isn't going to work the way it's supposed to.




回答2:


My guess is that each request by the client will be seen as a new session by the server.




回答3:


If you happen to grab the request headers from your browser, you can see that a SessionID is part of the header. This is used by the server to determine which session belongs to which user.




回答4:


Instead of session id being passed via cookie, it is typically passed as a query string in the URL, or as a custom HTTP header. With the scenario you described, however, your user will never obtain a session because you have cookieless set to false.




回答5:


I have not implemented this personally. But it should be like:

As Cookiless=false in web.config file and browser has disabled cookies, when first request for the page comes, HTTP module will check for forms authentication cookie. Now it will be empty which send user to login page. Now when second request for any page on website will come it will again find forms authentication cookie empty and send user to login page. So for every request user needs to create new session.




回答6:


No, If cookies are disable the session will not work.

if you want to use session when cookies disable then you can pass session thru URL.




回答7:


It stores directly in the browser




回答8:


There are two ways session state can store the unique ID that associates client with server session; by storing an HTTP cookie on the client or by encoding the session ID in the URL.

Session Mode="InProc" is a default mode which stores the session state information in web server. However when you say cookieless="false" you are saying to stored unique ID in cookie. This Id is created when session is created, so during postback ID is picked up from cookie. If cookie are disabled in browser,yes session still will be created and this id is passed along URL.

You can browse to cookies by going to browser settings->Privacy->Content Settings->All cookie and site data->Stored with site name Probable you might find cookies in %userprofile%\AppData\Roaming\Microsoft\Windows\Cookies but might differ from operating system to system.

In cookies you usually store small piece of insensitive personal information. If you need to store sensitive data such as user name and password it is better to encrypt those data.

In cookie you usually store information about the users. For more details please visit URL http://msdn.microsoft.com/en-us/library/system.web.configuration.sessionstatesection.cookieless(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/ff647070.aspx#pagexplained0002_cookielessforms




回答9:


Each request creates new session



来源:https://stackoverflow.com/questions/1401325/where-is-session-stored-if-cookie-is-disabled-on-clients-machine-what-is-actua

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!