Alternative for sessions in mvc4
could you please tell me what is the alternative for sessions in mvc4?..
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jun 3, 2014, 4:41 AM
Hi sasi,
I think, there is no alternative for session. yes you can use cookies to stored data but coockies is not good way to stored the data because it stored in client side.
you can use tempdata also but tempdata has limited life (up to one request) also Tempdata use session internally :)
Jignesh TrivediPosted Jun 5, 2014, 1:30 AM
you mean to say caching type data in which there is common data for every user?
if yes than refer my article
http://www.c-sharpcorner.com/UploadFile/ff2f08/caching-in-mvc-application-with-entity-framework-using-query/
hope this will help you.
Sasi ReddyPosted Jun 4, 2014, 9:24 AM
Anupam SinghPosted Jun 3, 2014, 2:54 AM
:)
Lakshmanan Sethu SankaranarayanPosted Jun 3, 2014, 2:45 AM
I agree with you. But if you are not concerned with the client side, its best to use cookies than application objects for storing information pertaining to a single user.
Anupam SinghPosted Jun 3, 2014, 2:23 AM
I would not suggest that. B'coz cookies and cache are client side. and session stores data on server. So session cannt be replaced by cookies or cache.
Hi Sasi,
You can use application level variables called global variables
see more information here :
http://www.c-sharpcorner.com/UploadFile/051e29/session-and-application-in-Asp-Net/
Lakshmanan Sethu SankaranarayanPosted Jun 3, 2014, 2:08 AM
Please check the code in the link http://stackoverflow.com/questions/19128507/using-cookie-in-asp-net-mvc-4 for usage of cookies.
Cookies stores the value in your personal computer. and Sessions are stored in memory of the server.
Link is http://stackoverflow.com/questions/19128507/using-cookie-in-asp-net-mvc-4
Sasi ReddyPosted Jun 3, 2014, 1:34 AM
Lakshmanan Sethu SankaranarayanPosted Jun 3, 2014, 1:26 AM
Please try using caches or cookies if you dont want session.