How to implement Cookieless Session in ASP. Net

By default ASP.Net relies on cookies to store session id. Cookies are actually a text data which is stored in browser. Generally cookies are not considered a safe way to store information. Also there is a chance that browser have disabled the cookies and in that case our application wont work on that browser.

To avoid such situation, we can use Cookieless session. To implement that you just need to set cookieless attribute to true in your session tag. Here is how you can do this:-
<system.web>
  <sessionState mode="InProc" cookieless="true" timeout="120" />
</system.web>

Once you have done that your URL will contain the session id, here is the snapshot of URL before and after implementing cookieless=true:-
As you can see that in the URL session id is visible.

Feel free to share your comments, Happy Codding !!!

Comments (6)

Loading... Logging you in...
  • Logged in as
Syed Azam Jaffri's avatar

Syed Azam Jaffri · 699 weeks ago

Very nice implementation Zeeshan. If you can put different implementation of state management with cookies that would be nice to see in this article. Keep up the good work.

Regards,
1 reply · active 688 weeks ago
Me working on this idea for some time, soon I will share that on my blog
thanks dear. so nice and small article but so clear concept.
1 reply · active 688 weeks ago

Post a new comment

Comments by