Reputation: 35
I want to define a variable or object like session, to stored data about each user, and i want to access this object in many pages, could u please tell me if there is a way. thanks
Upvotes: 0
Views: 331
Reputation: 1982
i've had a few situations where I wanted to minimize/eliminate session storage (due to users being on a horrible wifi connection). to handle this situation I used an encrypted query string with only their ID in the string. in the base page I would decrypt the string and pull information I needed from the database. This information would be populated into objects that I defined and since the objects were in the base page I could access the information from any pages that inherited it.
Upvotes: 0
Reputation: 383
You can store data in a cookie and then in your codebehind parse the specific cookie into something like a System.Collections.Generic.Dictionary
But you should use sessions.
Edit
IF if's a KeyValuePair<String,TValue>
you can set Session[kvp.Key] = kvp.Value;
, if not Session["KVP"] = kvp;
Upvotes: 0
Reputation: 486
If u really don't want to use session use Database mind that this is a slow method...
Upvotes: 0
Reputation: 42165
You have onlyy a few choices, really. URL parameters, hidden form inputs, cookies, session (be careful in a load-balanced scenario) or just store/retrieve stuff from a database. RaveDB is bloomin' brilliant for this because it's so fast and document-based.
Upvotes: 1