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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 3, 2014, 12:41 AM EDT
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 :)
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Jun 2, 2014, 9:26 PM EDT
Please try using caches or cookies if you dont want session.
Sasi ReddyRank #4,458 · 342 reputationPosted Jun 2, 2014, 9:34 PM EDT
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Jun 2, 2014, 10:08 PM EDT
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
Anupam SinghRank #643 · 3.7K reputationPosted Jun 2, 2014, 10:23 PM EDT
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 SankaranarayanRank #124 · 17.7K reputationPosted Jun 2, 2014, 10:45 PM EDT
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 SinghRank #643 · 3.7K reputationPosted Jun 2, 2014, 10:54 PM EDT
:)
Sasi ReddyRank #4,458 · 342 reputationPosted Jun 4, 2014, 5:24 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 4, 2014, 9:30 PM EDT
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.