Hi all,
I have interesting problem. Something we have all encountered before ...
browser inconsistencies. This is related to handling session timeouts on an
ajax request. I'll just layout our current setup.
We have a symfony filter that detects whether the current request is an XML
HTTP Request and if the current user session has timed out. The code for
this is:
if ($user->isAuthenticated() == false && $request->isXmlHttpRequest())
{
return $context->getController()->redirect('users/ajaxTimeout'); exit;
}
As you can see if the IF conditions are met it redirects to another action
whose code is:
sfContext::getInstance()->getResponse()->setHttpHeader("Content-Type",
"application/json");
return $this->renderText(json_encode(array("error"=>"session",
"url"=>"users/login")));
We also have our jQuery .ajaxSetup as follows on the success callback:
success : function(response, textStatus, xmlobject) {
try {
var json_res = jQuery.parseJSON(response);
if (json_res.error == "session")
{
window.location.href = json_res.url;
}
}
catch (e)
{
}
The workflow is that as soon as an ajax request is made, the filter catches
the request, and detects the request is AJAX and session has timed out so
redirects the request to the action code above. The action responds with a
JSON string which the global .ajaxSetup success callback catches and sees
that there is a session error and redirects the entire page to the login
screen.
It works well in Firefox and IE however in Chrome it doesn't. I was
wondering if anyone here might have some insight into what might be causing
the problem.
--
Gareth McCumskey
http://garethmccumskey.blogspot.com
twitter: @garethmcc
identi.ca: @garethmcc
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en