Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get session variables from a class file?

Any one familiar with SocialAuth.NET ?? Kindly follow this link to checkout SocialAuth.NET . Integrates seamlessly with a lot of providers such as Facebook, Twitter, Google etc.

Okay, enough introduction. Now, SocialAuth.NET stores everything in session. For e.g to get the Facebook User ID we call SocialAuthUser.GetCurrentUser.GetProfile.ID , since it is session based i get this error message "Object Reference Not Set to an instance of an object" when i try to call SocialAuthUser.GetCurrentUser.GetProfile.ID from a webservice or a class file.

Any idea how do i get it to work for me in a class file?? Any help immensely appreciated.

If this System.Web.HttpContext.Current.Session("NameHere") is what i should use..what should go into the braces??

UPDATE: Kindly do not flag this question as Duplicate . I have seen this Question, and not sure if this is what i should do.

like image 910
Monodeep Avatar asked Dec 10 '25 01:12

Monodeep


1 Answers

I implemented IRequireSessionState for the classes where i was making these calls. This was to make the class aware of the current session state.

like image 61
Monodeep Avatar answered Dec 12 '25 15:12

Monodeep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!