6
votes

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?

9
I know that if I set cookieless to true then the sessionid is appended to the url, but i just want to know if the cookiesless value is set to false and the client has disabled the cookies on his machine will the application behave properly or will break away. I personally feel that the application wont work as answered by Josh Stodola.Panache
Take a look at the note on the bottom of my post. In a sentence, the app will break if you completely disable cookies and still expect session to be there, and don't enable cookieless sessions. For instance, I actually ran a test and on one of my apps I just kept getting the login screen.Brian MacKay
I have created a sample application with session attribute cookieless set to false and disabled the cookies in browser and tested the application it just works fine. where is the session values stored?Panache
Check thisJibin
stackoverflow.com/questions/12572134/… this thread will answer your query.Varshaan

9 Answers

18
votes

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.

0
votes

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

0
votes

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.

0
votes

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.

0
votes

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.

0
votes

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.

0
votes

It stores directly in the browser

0
votes

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

-5
votes

Each request creates new session