how Server judge an Ajax Request belongs to a Session

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mentor
    New Member
    • Mar 2007
    • 24

    how Server judge an Ajax Request belongs to a Session

    When user is authenticated, the server store "UserName" in session. Then throug ajax, the user request another page which require authentication. How the ajax request tell the server that one has been authenticated, or how the server know it's from 'UserName"?

    Should ajax set SessionId in Header or Cookie ? How to get and set the SessionId ?

    I learned the browser could send back to server a sessionid, but I don't know how this should be done in JS.

    I'm using JQuery, C#.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Post some code that we can have a look at. Have you tried setting the session id without Ajax and got it all working fine?

    Comment

    • rnd me
      Recognized Expert Contributor
      • Jun 2007
      • 427

      #3
      Originally posted by mentor
      When user is authenticated, the server store "UserName" in session. Then throug ajax, the user request another page which require authentication. How the ajax request tell the server that one has been authenticated, or how the server know it's from 'UserName"?

      Should ajax set SessionId in Header or Cookie ? How to get and set the SessionId ?

      I learned the browser could send back to server a sessionid, but I don't know how this should be done in JS.

      I'm using JQuery, C#.

      my ajax code usually (in firefox at least) will automatically pop-up a login box if needed. the browser should handle this, it not something to worry about in js.

      ajax will use the page's connection to the server.
      when your page's connection times-out, so does the ajax auth.

      does that help?

      Comment

      • mentor
        New Member
        • Mar 2007
        • 24

        #4
        So I see that ajax will use the page's connection to the server. That's Ok, Thanks !

        Originally posted by rnd me

        ajax will use the page's connection to the server.
        when your page's connection times-out, so does the ajax auth.

        does that help?

        Comment

        Working...