Global function to retrieve object from Session

A

awburns

Hi,

A friend of mine has written a C# Assembly to get some data. To do so,
though, involves creating an object ( a 'Login' object, containing the
user's credentials) and then running a "login()" method.

I'd like to store this in the Session object, to avoid having to login
for each page. What's the best way of doing this? And how would I
write a global function for accessing this data from the Session
object?

Thanks, Andy.
 
G

Guest

You can store pretty much anything that's serializable in Session State. All
you do is write
Session["myKey"]= myObject;

to retrieve, you need to cast it out:

MyObject myObject = (MyObject)Session["myKey"];

However, the real issue here is that your "friend" probably should have used
the built-in ASP.NET Membership, Roles, and Profile providers to build a more
scalable authentication and authorization scheme that handles this kind of
stuff autmatically.

The moral is, choose your friends.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top