locked
Can I access another website's session? RRS feed

  • Question

  • User-319520546 posted

    I have two IIS server. They are on different PCs.
    PC A's IIS run WebSite A;
    PC B's IIS run WebSite B;

    And the two WebSites' Session are stored in StateServer.
    There is only one StateServer, and the StateServer is on PC A.

    Is there a way to let WebSite B to access WebSite A's Session?

    Any tips will be appreciated! Thanks in advance.

    Tuesday, July 26, 2011 1:34 AM

Answers

  • User780011528 posted

    not at all u cant , think about it if u can do this what about the security? it really might not possible but it can be possible 

    the following way

    storing session data in a SQL Server database. It is the most reliable option but the least performing one.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 26, 2011 2:12 AM
  • User-1359474226 posted

    Hi

    Did you try this link.

    http://www.codeproject.com/KB/session/sharedsession.aspx

    This lik is provided in one of the above post.

    Thank You

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 27, 2011 11:11 AM

All replies

  • User780011528 posted

    not at all u cant , think about it if u can do this what about the security? it really might not possible but it can be possible 

    the following way

    storing session data in a SQL Server database. It is the most reliable option but the least performing one.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 26, 2011 2:12 AM
  • User-1637433209 posted

    See this thread

    http://forums.asp.net/t/1478697.aspx

    Tuesday, July 26, 2011 2:14 AM
  • User-319520546 posted

    Thank you all.

    I've tried the solutions provided by the link. But I found that they are all about DB Session State.
    Is there some solution about StateServer?

    I know that the question is curious, but it do make sense to our project.
    If there isn't any solution, maybe we have to turn to other direction.

    Tuesday, July 26, 2011 9:22 PM
  • User-319520546 posted

    I found a solution by googling.
    What follows are detail:
    "System.Web.SessionState.OutOfProcSessionStateStore" class has a static private filed "s_uribase",
    using reflection we can set the filed as same value for every website, which should share session.
    We can define a class which implement the IHttpModule, then we can do the above reflection in the IHttpModule.Init method.
    beyond that, we should set the "machineKey" as the same value for every website in the web.config.

    the solution is in a Chinese blog:
    http://www.cnblogs.com/xinhaijulan/archive/2010/08/21/1805116.html

    There has full version code.

    But this isn't a perfect solution, when the WebSite A and WebSite B are on the same PC, the same IIS, it worked.
    But when they are on different PC, it doesn't work.

    Dose anyone know why it works?
    And why it doesn't work when the websites are on different PCs?
    Should I change other fileds by reflection to make it work?

    Wednesday, July 27, 2011 3:25 AM
  • User-1359474226 posted

    Hi

    Did you try this link.

    http://www.codeproject.com/KB/session/sharedsession.aspx

    This lik is provided in one of the above post.

    Thank You

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 27, 2011 11:11 AM