Cannot Retrive a value using from HttpCookie (VB.NET) RRS feed

  • Question

  • User-1846541499 posted

    Hi everybody,

    In Global.asax file, I create a cookie (HttpCookie) and store the cookie value like below.

        Session.Item("SessionID") = oCookie.Value

    okay.when step into code during the runtime the value is stored in the SessionID.

    when try to get the value of Session.Item("SessionID") like below.

    Friend Shared Function GetUserSessionID(ByRef Context As HttpContext) As String

            'Retrieve session id from session state as would have been setup on start of session

            Dim strSessionID As String = ""

          If Context.Session.Item("SessionID") <> "" Then
                strSessionID = Context.Session.Item("SessionID")
                strSessionID = Replace(Guid.NewGuid.ToString, "-", "")
            End If

            Return strSessionID

        End Function

    (inside the project) 

    the value is not coming in variable strSessionID.which was stored by cookie in Global.asax file.


    Friday, August 5, 2011 1:40 AM

All replies

  • User-738352979 posted

    in which event ur writing this value in global.asax

    Session.Item("SessionID") = oCookie.Value

    and check the value of cookie at the time of writing.........



    Friday, August 5, 2011 1:58 AM
  • User-1846541499 posted

    hi somnath,

    i am writing this value in the session start event in the global.asax file.

    Session_Start(ByVal sender As Object, ByVal e As EventArgs)


    i checked the value of cookie - it showing a value but that value 

    is not coming inside the project. i dont know why?

    Friday, August 5, 2011 2:07 AM
  • User-1846541499 posted

    Hi everybody,

    itz very urgent .please gave me some solution ...

    Friday, August 5, 2011 9:23 AM
  • User-1177472553 posted

    set the value into session Session["data"]=ocookie.value;

    then retrieve it like HttpContext.Current.Session["data"]

    Tuesday, August 16, 2011 10:09 AM