Forum Discussion

ddidonato's avatar
ddidonato
Creator II
3 years ago

Session ID

Is there a way I can retrieve the current session id from a method?

4 Replies

  • Maybe something like this?

    HttpContext.Current.Session.SessionID 

  • That didn't work. Here is the code Below is the code I'm trying to use it for:

    string xx = CStr(CCO.Session("arasSESSID"));
    for (int i = 0 ; i<this.getItemCount() ; i++)
    {
        Item currentW = this.getItemByIndex(i);
            String SQL = "Select (SELECT TOP(1) MIN_PORTAL_STORE_ACCOUNTS.CONTACT_ID FROM MIN_PORTAL_STORE_ACCOUNTS WHERE MIN_PORTAL_STORE_ACCOUNTS.SESSION_ID = " +  "'" + xx + "'" + ")" + " as nb";
            SQL = String.Format(SQL,currentW.getProperty("config_id","error"));
            Item res = currentW.getInnovator().applySQL(SQL);

            if (!res.isError())
            {
                string nb = res.getProperty("nb","");
                currentW.setProperty("id",nb);
            }
    }

    return this;

    • angela's avatar
      angela
      Catalyst II

      CStr is a VB function, not a C# function. Use something like this: CCO.Session["arasSESSID"].ToString();

      My first post showed a variant to get the ASP.NET_SessionId as stored in the cookies. Where did you find the information about "arasSESSID!? Which session id does this one reference to? Can you give some insights to your use case?

      Thanks!

      • ddidonato's avatar
        ddidonato
        Creator II

        Thanks Angela, that worked. It also works if I rewrite my code to VB using CStr(CCO.Session("arasSESSID")). The arasSESSID retrieves the current session id. TY!