Answered by:
Session, Query String or Cookies?

Question
-
User2103817411 posted
Hi,
here is my question, i have to move a value across all pages visit in my site that im developing. if i use a session, the session expired even though the current logged session doesnt expired. if i decide to use a query string, that mean i have to be passing the query string to all the link. i dont know about using cooking that much that is im seeking for your advice.
Please is there a way to achieve this.
thanks.
Monday, June 22, 2015 12:15 AM
Answers
-
User177399542 posted
Hi ibcent2003
Yes you can use cookies to store and retrieve values from multiple pages of the website. Here is an example:
http://www.codingfusion.com/Post/Cookies-in-asp-net
Note: Make sure not to store any sensitive data in cookies. Cookies can be easily modified. You can Encrypt or decrypt cookies in asp .net to apply security.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 22, 2015 2:06 AM -
User-484054684 posted
There may also be better options instead of using cookies, especially when the data you want to share across is "sensitive".
As you might know, cookies are stored in client side on browser (something like text files). So, it is essential to understand what kind of data you would want to share across.
If you would like to use more secure mechanism, on server side, you can go with Application or Cache variables as well.
For complete information on the state management principles, I would recommend to go through this nice article from MSDN:
https://msdn.microsoft.com/en-us/library/75x4ha6s%28v=vs.140%29.aspx
From code project: http://www.codeproject.com/Articles/331962/A-Beginner-s-Tutorial-on-ASP-NET-State-Management
Regarding usage of Cache variables for storing data/objects, you can refer these articles:
See Data Caching from http://www.codeproject.com/Articles/6158/Caching-in-ASP-NET
See Object Caching from http://www.tutorialspoint.com/asp.net/asp.net_data_caching.htm
For complete reference from MSDN: https://msdn.microsoft.com/en-us/library/System.Web.Caching.Cache%28v=vs.110%29.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 22, 2015 5:30 AM
All replies
-
User177399542 posted
Hi ibcent2003
Yes you can use cookies to store and retrieve values from multiple pages of the website. Here is an example:
http://www.codingfusion.com/Post/Cookies-in-asp-net
Note: Make sure not to store any sensitive data in cookies. Cookies can be easily modified. You can Encrypt or decrypt cookies in asp .net to apply security.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 22, 2015 2:06 AM -
User2103817411 posted
Thanks anuj_koundalMonday, June 22, 2015 3:58 AM -
User-484054684 posted
There may also be better options instead of using cookies, especially when the data you want to share across is "sensitive".
As you might know, cookies are stored in client side on browser (something like text files). So, it is essential to understand what kind of data you would want to share across.
If you would like to use more secure mechanism, on server side, you can go with Application or Cache variables as well.
For complete information on the state management principles, I would recommend to go through this nice article from MSDN:
https://msdn.microsoft.com/en-us/library/75x4ha6s%28v=vs.140%29.aspx
From code project: http://www.codeproject.com/Articles/331962/A-Beginner-s-Tutorial-on-ASP-NET-State-Management
Regarding usage of Cache variables for storing data/objects, you can refer these articles:
See Data Caching from http://www.codeproject.com/Articles/6158/Caching-in-ASP-NET
See Object Caching from http://www.tutorialspoint.com/asp.net/asp.net_data_caching.htm
For complete reference from MSDN: https://msdn.microsoft.com/en-us/library/System.Web.Caching.Cache%28v=vs.110%29.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 22, 2015 5:30 AM