Retriving session ID from one web application and passing to other application

Posted on 2006-05-08
Last Modified: 2010-04-17
I have one web application in .net. Upon the login to this application it
creates a session ID.

I Want to use this session id created by this application in other web application.

How do I retrive and pass the session id to other application.

Pls Help.
Question by:r_pat72
    LVL 3

    Accepted Solution

    The simplest way is to use Http Post or Http Get to pass it along when calling a page in the other application.

    How to retrieve it? You can get it from Session.SessionID.
    LVL 2

    Expert Comment

    You can create a list (an ArrayList) that holds all the current sessionID's and save it to Application["SessionArrayList"]. Then all your clients can access this list.

    If you want only one session ID, you do not need a list.
    LVL 2

    Expert Comment

    If they are completely different applications, you can send it by querystring to other application:

    Response.Redirect("" & Session.SessionID)

    Author Comment

    The application that setting specifically session id in cookie. I don't have access to the code of that application but i can login to that application using user id and password.

    When I login to that application it sets the seeionid in a cookie as response["sessioid"] = "xxxx"

    How will I read that session ID from cookies in my application.

    I did request["cookies"].But it doesn't return anything.
    LVL 2

    Assisted Solution

    public static HttpCookie GetCookie(string key)
                      //encode key for retrieval
                      key = HttpContext.Current.Server.UrlEncode(key);
                      return HttpContext.Current.Request.Cookies.Get(key);

                public static string GetCookieValue(string key)
                      string value = "";

                            //get value
                            HttpCookie cookie = GetCookie(key);
                            if (cookie != null)
                                  value = cookie.Value;
                                  //decode stored value
                                  value = HttpContext.Current.Server.UrlDecode(value);
                      catch (Exception ex)
                            string e = ex.Message;
                      return value;


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    factory design pattern vs abstract factoy design pattern 2 63
    scores100 challenge 3 67
    wordsWithout 49 64
    array11 challenge 16 40
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    A short article about problems I had with the new location API and permissions in Marshmallow
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now