Sum
Sum

Reputation: 35

How to define Variable similer to Session variable in ASP.NET

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

Answers (4)

peroija
peroija

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

Max Keller
Max Keller

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

Prabhavith
Prabhavith

Reputation: 486

If u really don't want to use session use Database mind that this is a slow method...

Upvotes: 0

Neil Barnwell
Neil Barnwell

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

Related Questions