By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,683 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,683 IT Pros & Developers. It's quick & easy.

Global function to retrieve object from Session

P: n/a
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.

Jun 4 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"aw*****@gmail.com" wrote:
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.

Jun 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.