Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi
can anyone please tell me in session and cookie which is most secure?

Thank u
Posted

If you need a one line answer - Sessions are more safe then cookies.

But in real applications, it is not so straight forward. we need to consider a lot of things before deciding on which state management should be used. i suggest read something on state management and decide.

Hopefully this article will give you some answers you are looking for: A Beginner's Tutorial on ASP.NET State Management[^]
 
Share this answer
 
Comments
Pankaj Nikam 26-Jun-12 6:42am    
+5 Awesome answer :)
Rahul Rajat Singh 26-Jun-12 6:43am    
thank you.
Session state consumes either RAM or database resources, depending on which provider you use (InProc vs. SQL). It also requires a cookie, in order for the server to associate an incoming request with a particular Session collection.

For something like a site ID, I would suggest storing it in a cookie if you can. For best performance, configure the cookie with a path property so the browser doesn't include it with requests for images and other static files.

Refer similar thread: Session vs Cookie[^]
 
Share this answer
 
Comments
Rahul Rajat Singh 26-Jun-12 6:10am    
good answer. +5.
Prasad_Kulkarni 26-Jun-12 6:11am    
Thank you Rahul!
Pankaj Nikam 26-Jun-12 6:42am    
Usage of RAM or Database Resource is a good point to mention :) My +5 :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900