Connecting Tech Pros Worldwide Forums | Help | Site Map

how Server judge an Ajax Request belongs to a Session

Newbie
 
Join Date: Mar 2007
Location: china
Posts: 24
#1: Feb 21 '08
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's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Feb 21 '08

re: how Server judge an Ajax Request belongs to a Session


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?
rnd me's Avatar
Expert
 
Join Date: Jun 2007
Location: Urbana IL
Posts: 411
#3: Feb 21 '08

re: how Server judge an Ajax Request belongs to a Session


Quote:

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?
Newbie
 
Join Date: Mar 2007
Location: china
Posts: 24
#4: Mar 9 '08

re: how Server judge an Ajax Request belongs to a Session


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

Quote:

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?

Reply