Session is not always available. For example, when the XSS (cross-site scripting) security settings in IE prevent the storage of third-party cookies. If your site is called in an IFrame from a site that is not your DNS domain, your cookies will be blocked by default. No cookies = no session.
Another example: you need to transfer control to another site that will make the callback on your site a pure URL, not mail. In this case, you need to save the session parameters in the querystring parameter, which is very difficult to do, given the 4k size limit and URL encoding, not to mention encryption, etc.
The problem is that most of the built-in serialization methods are pretty detailed, so you have to resort to the roll-your-own method, possibly using reflection.
Another reason not to use sessions is simply to improve user experience; Sessions are cleared after N minutes and upon server restart. Well, in this case viewstate is preferable, but sometimes it is impossible to use a form. Well, one could use JavaScript for postback, but again, this is not always possible.
These are the problems that I am currently coding.
source share