Store a value to Session

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/31/2011 5:45:17 AM
Gravatar
Total Posts 2

Store a value to Session

I want to store some value in session, when the user successfully login into the system. So how do i store the vaue in Session.

Regards

Bikarm

1/31/2011 10:03:44 AM
Gravatar
Total Posts 245
mojoPortal Community Expert

Re: Store a value to Session

Hi

In C# code...

// To Store a Session var

string firstName = "Jeff";
string lastName = "Smith";
string city = "Seattle";
Session["FirstName"] = firstName;
Session["LastName"] = lastName;
Session["City"] = city;

// To Read a Session Var

string firstName = (string)(Session["First"]);
string lastName = (string)(Session["Last"]);
string city = (string)(Session["City"]);

You can store anything in a session var, even a DataTable

Hope this helps

Rick(ARVIXE)

1/31/2011 9:45:04 PM
Gravatar
Total Posts 2

Re: Store a value to Session

sorry, i haven't clarify my problem, the problem is i am not in any asp.net page, so i think i can't use Session, here is my piece of code, when the user signs in.

 

 public class MYUserSignInEventHandler : UserSignInHandlerProvider
    {
        private static readonly ILog log= LogManager.GetLogger(typeof(DoNothingUserSignInHandlerProvider));

        public MYUserSignInEventHandler()
        { }

        public override void UserSignInEventHandler(object sender, UserSignInEventArgs e)
        {
            if (e == null) return;
            if (e.SiteUser == null) return;

            try
            {
               
                 string sessionID=SBOWebServices.GetSessionID();
               
               
            }
            catch (Exception ex)
            {
                throw ex;
            }
            // do nothing
            log.Debug("DoNothingUserSignInHandlerProvider called for user " + e.SiteUser.Email);
        }
    }

 

Here in this event i want to store the sessionID value in session or cookie, so that the user can use this value until he is not logged out of the system.

 

Regards

Bikram

2/1/2011 11:35:36 AM
Gravatar
Total Posts 18439

Re: Store a value to Session

if (System.Web.HttpContext.Current != null)
{
      System.Web.HttpContext.Current.Session["foo"] = "bar";
}

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.