locked
How could implement ISessionIDManager RRS feed

  • Question

  • User858638481 posted

    Hi guys,

    I would like implement this interface to create my own SessionID for cookieless mode to use session on mobiles.
     

    public void SaveSessionID(HttpContext context, string id, out bool redirected, out bool cookieAdded)
    {
      redirected = false;
      cookieAdded = false;
    
      if (pConfig.Cookieless == HttpCookieMode.UseUri)
      {
        // Add the SessionID to the URI. Set the redirected variable as appropriate.
    
        redirected = true;
        return;
      }
      else
      {
        context.Response.Cookies.Add(new HttpCookie(pConfig.CookieName, id));
        cookieAdded = true;
      }
    }

     // Add the SessionID to the URI. Set the redirected variable as appropriate.

    I don't know how to do that???
    I don't find the URI in the httpcontext

    Thanks
     

    Monday, March 5, 2007 8:46 AM

Answers

  • User-1087479560 posted
    Hi,

    You may implement it like this in SaveSessionID method.

    public void SaveSessionID(HttpContext context, string id, out bool redirected, out bool cookieAdded){
    string text = this.Encode(id);
    context.CookielessHelper.SetCookieValue('S', text);
    HttpRequest request = context.Request;
    string url = request.Path;
    string queryStringText = request.QueryStringText;
    if (!string.IsNullOrEmpty(queryStringText))
    {
    url = url + "?" + queryStringText;
    }
    context.Response.Redirect(url, false);
    context.ApplicationInstance.CompleteRequest();
    redirected = true;
    }

    Hope it helps.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 14, 2007 4:01 AM
  • User858638481 posted

    Thanks :)

    But with your code the session is not in the url path ?

    I solved my problem last week : 

    I thank my problem was the '(' in the url but it was not.

    I had just put a new line in the web config and my mobile could accept my website :

    <httpRuntime useFullyQualifiedRedirectUrl="true" />
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 14, 2007 4:13 AM

All replies

  • User-1087479560 posted
    Hi,

    You may implement it like this in SaveSessionID method.

    public void SaveSessionID(HttpContext context, string id, out bool redirected, out bool cookieAdded){
    string text = this.Encode(id);
    context.CookielessHelper.SetCookieValue('S', text);
    HttpRequest request = context.Request;
    string url = request.Path;
    string queryStringText = request.QueryStringText;
    if (!string.IsNullOrEmpty(queryStringText))
    {
    url = url + "?" + queryStringText;
    }
    context.Response.Redirect(url, false);
    context.ApplicationInstance.CompleteRequest();
    redirected = true;
    }

    Hope it helps.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 14, 2007 4:01 AM
  • User858638481 posted

    Thanks :)

    But with your code the session is not in the url path ?

    I solved my problem last week : 

    I thank my problem was the '(' in the url but it was not.

    I had just put a new line in the web config and my mobile could accept my website :

    <httpRuntime useFullyQualifiedRedirectUrl="true" />
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 14, 2007 4:13 AM
  • User-1087479560 posted
    Session itself is saved to the medium in SessionModule, and sessionIDManager is responsible for saving the id of the session to some place(cookie, querystring) so that another request from the same client comes, asp.net is able to retrieve its session state with this id.
    Wednesday, March 14, 2007 4:26 AM
  • User858638481 posted

    But I wanted to rewrite how the session was stocked in the url path. On mobile phone you can't stock cookie to save the session ID. I solved my problem with the web.config, I found an implementation of ISessionIDManager with Mono Sources and it was very interresting.

    Thanks for your help

     

    Wednesday, March 14, 2007 4:39 AM
  • User-1087479560 posted
    Just an advice, if you need to change the way how session is stored, I think you can implement another SessionStateModule rather than SessionIDManager.
    Wednesday, March 14, 2007 4:46 AM
  • User-899814307 posted

    I have the same problem i'm trying to change the sessionid place in the url i will appreciate

    an example of the implementation you used.

    Thanks in advance.

     

    Friday, December 4, 2009 4:23 PM