Ext


Go Back   Ext JS Forums > Ext JS Community Forums (2.0) > Ext 2.x: Help

Reply
 
Thread Tools
  #1  
Old 03-14-2008, 05:36 AM
shjy.nicholas's Avatar
shjy.nicholas shjy.nicholas is offline
Ext User
 
Join Date: Jan 2008
Location: Shanghai, China
Posts: 9
shjy.nicholas is on a distinguished road
Send a message via MSN to shjy.nicholas
Exclamation Why always change session id?

Dear, Everybody,
When i user Ext.Ajax.request, the server side always get a new session id.
Even a very simple case,
such as
Ext.Ajax.request({
url: '/test/testLogin/',
success: function() {alert('success')},
failure: function() {alert('failure')},
params: { uid: new Date().getTime(), uname: new Date().getTime() }
});

the server codeJava Servlet)
System.out.println("Sesseion id: " + request.getSession().getId());
System.out.println("uid: " + request.getParameter("uid"));
System.out.println("uname: " + request.getParameter("uname"));

The terminal prints:
Sesseion id: 9CEA218F32ACF766B339EDD174FEBB04
uid: 1205486576312
uname: 1205486576312
Sesseion id: FFBD081EF41AE538B7168943460F8DBF
uid: 1205486583578
uname: 1205486583578

But, in my application,
First, I need send a ajax request to the server, in order to get a validate code as a picture,
Then, when submit, I need to check the validate code at the server side. But the check process needs the same session id when the first used.

Is there anybody know how to fix it? I'm waiting...
Reply With Quote
  #2  
Old 03-14-2008, 08:21 AM
cerad's Avatar
cerad cerad is offline
Ext User
 
Join Date: Dec 2007
Posts: 157
cerad is on a distinguished road
Default

Is your server sending back the session id in a cookie? You can use Firebug to see whats going on but it sounds like your server is never setting the initial session id.
Reply With Quote
  #3  
Old 03-14-2008, 09:41 AM
michaelc's Avatar
michaelc michaelc is offline
Ext JS Premium Member
 
Join Date: Dec 2007
Location: Bay Area - CA
Posts: 381
michaelc is on a distinguished road
Send a message via AIM to michaelc
Default

Quote:
Originally Posted by shjy.nicholas View Post
Dear, Everybody,
When i user Ext.Ajax.request, the server side always get a new session id.
Even a very simple case,
such as
Ext.Ajax.request({
url: '/test/testLogin/',
success: function() {alert('success')},
failure: function() {alert('failure')},
params: { uid: new Date().getTime(), uname: new Date().getTime() }
});

the server codeJava Servlet)
System.out.println("Sesseion id: " + request.getSession().getId());
System.out.println("uid: " + request.getParameter("uid"));
System.out.println("uname: " + request.getParameter("uname"));

The terminal prints:
Sesseion id: 9CEA218F32ACF766B339EDD174FEBB04
uid: 1205486576312
uname: 1205486576312
Sesseion id: FFBD081EF41AE538B7168943460F8DBF
uid: 1205486583578
uname: 1205486583578

But, in my application,
First, I need send a ajax request to the server, in order to get a validate code as a picture,
Then, when submit, I need to check the validate code at the server side. But the check process needs the same session id when the first used.

Is there anybody know how to fix it? I'm waiting...
the other item that can occur, if you clear cache and remove your cookies you could get a new session each time.

your server could have a timeout set real low - like zero but I have never seen this, but you should keep a valid session and this is not an ajax or extjs issue.
Reply With Quote
  #4  
Old 03-14-2008, 09:54 AM
ktp ktp is offline
Ext User
 
Join Date: Jul 2007
Posts: 21
ktp is on a distinguished road
Default

I use Ext in serveral selfwritten frameworks with sessions.
I had no problems using ajax.
Are you shure you aren't overwriting variables?
Quote:
Ext.Ajax.request({
url: '/test/testLogin/',
success: function() {alert('success')},
failure: function() {alert('failure')},
params: { uid: new Date().getTime(), uname: new Date().getTime() }
});
Sincerely yours, ktp.
Reply With Quote
  #5  
Old 03-14-2008, 02:26 PM
shjy.nicholas's Avatar
shjy.nicholas shjy.nicholas is offline
Ext User
 
Join Date: Jan 2008
Location: Shanghai, China
Posts: 9
shjy.nicholas is on a distinguished road
Send a message via MSN to shjy.nicholas
Default Details in Firebug

Hello everyone,
I really have no idea about this, i have tried server different ways.
In FF, i user firebug to see the details, the following information is showing in Firebug:

Response Headers
Server Apache-Coyote/1.1
Content-Type text/html
Transfer-Encoding chunked
Date Fri, 14 Mar 2008 10:19:02 GMT
Request Headers
Host localhost:8810
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
Accept text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language zh-cn,zh;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
X-Requested-With XMLHttpRequest
Content-Type application/x-www-form-urlencoded
Referer http://localhost:8810/test/testLogin.jsp
Content-Length 37
Cookie JSESSIONID=3905A277B7A137DA5E05F322294B50FE; seraph.os.cookie=LkFlIlGkCpDlLiEiMiOiKiGiHjGpNjDiFiMjHiFiNnPnCm
Pragma no-cache
Cache-Control no-cache

I remember that, I have test this program two months ago, but now, it does not works any more, and i can not find where the bug is.
Reply With Quote
  #6  
Old 03-14-2008, 02:33 PM
shjy.nicholas's Avatar
shjy.nicholas shjy.nicholas is offline
Ext User
 
Join Date: Jan 2008
Location: Shanghai, China
Posts: 9
shjy.nicholas is on a distinguished road
Send a message via MSN to shjy.nicholas
Post Supplemental

I have write two simple Java Servlet to test the session id.
but the result is right, and the session is never re-new anymore.
That means, may be, the problem is the Ajax?
Reply With Quote
  #7  
Old 03-17-2008, 08:37 AM
cerad's Avatar
cerad cerad is offline
Ext User
 
Join Date: Dec 2007
Posts: 157
cerad is on a distinguished road
Default

Check what is being sent back to the server in the ajax request. The cookies should be in there. If not then you might have a domain or expiration problem.
Reply With Quote
  #8  
Old 10-07-2008, 11:34 AM
redice redice is offline
Ext User
 
Join Date: Jun 2008
Posts: 1
redice is on a distinguished road
Default Why server get new session id?

Hi,
I encounter the same problem like shjy.nicholas said: use Ext.Ajax.request, web server always get a new session id.
the problem never happened in FF, but the problem always happened in IE6, or IE 7.
And another factor is on host name.
if FF, IE6, IE7 use ip address as url address, ex: http://192.168.0.12:8080/web, ajax request always send the same session id because browser keep the first set-Cookie value.
But IE6, IE7 use host name address, ex: http://abc_eu.bbb.net:8080/web, and the strange thing happened. server always get the different session id from every ajax request.
I found the different behavior on the set-Cookie http header.
IE6, IE7 didn't save session id in their cookies, maybe somebody will say: browser didn't allow to set cookie, but I did that all browser enable cookies.

I catch the http request/response message of IE7 when browser set session ind their cookie.
Although web server ask browser to set session in cookie by Set-Cookie:JSESSIONID=1c418adop85n1;Path=/webengine in the first response
but browser didn't save sessionid in cookie, so browser send the second request that don't have Cookie: JSESSIONID=1c418adop85n1
so web server can't accept JSESSIONID, and then create a new session id for non-sessionid request.

I don't know why FF, IE6, IE7 has different behavior on host name url address, if any idea or advice, I will be most appreciated. Please give me some direction to find the cause. thanks.

[first request]
Request Headers Value
(Request-Line) GET /webengine/ HTTP/1.1
Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/x-shockwave-flash, */*
Accept-Language zh-tw,en-us;q=0.5
UA-CPU x86
Accept-Encoding gzip, deflate
User-Agent Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; .NET CLR 2.0.50727)
Host abc_eu.bbb.net:8080
Connection Keep-Alive

Response Headers Value
Transfer-Encoding:chunked
Set-Cookie:JSESSIONID=1c418adop85n1;Path=/webengine
Server:Jetty(6.1.11)
Expires:Thu, 01 Jan 1970 00:00:00 GMT
Date:Tue, 07 Oct 2008 15:06:39 GMT
Content-Type:text/html; charset=utf-8
(Status-Line):HTTP/1.1 200 OK

////////////////////////////////////
[second request]
Request Headers Value
(Request-Line) GET /webengine/css/css_style.css HTTP/1.1
Accept */*
Referer http://abc_eu.bbb.net:8080/webengine/
Accept-Language zh-tw,en-us;q=0.5
UA-CPU x86
Accept-Encoding gzip, deflate
User-Agent Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; .NET CLR 2.0.50727)
Host abc_eu.bbb.net:8080
Connection Keep-Alive

Response Headers Value
Server Jetty(6.1.11)
Last-Modified Mon, 02 Jun 2008 08:49:26 GMT
Date Tue, 07 Oct 2008 15:06:40 GMT
Content-Type text/css
Content-Length 1710
(Status-Line) HTTP/1.1 200 OK
Reply With Quote
  #9  
Old 12-23-2008, 06:44 AM
malek malek is offline
Ext User
 
Join Date: Dec 2008
Posts: 1
malek is on a distinguished road
Thumbs up

Quote:
Originally Posted by redice View Post
if FF, IE6, IE7 use ip address as url address, ex: http://192.168.0.12:8080/web, ajax request always send the same session id because browser keep the first set-Cookie value.
But IE6, IE7 use host name address, ex: http://abc_eu.bbb.net:8080/web, and the strange thing happened. server always get the different session id from every ajax request.
That exactely what happened !
I'm not using Ajax, but I had probleme only in IE7, and removing "_" from url resolved it
Thank you very much Redice !
Malek

Last edited by malek; 12-23-2008 at 08:30 AM.. Reason: Resolved
Reply With Quote
Reply

Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 11:28 PM.

© 2006-2009 Ext, LLC
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.