Return session expired when loading grid from php

Hi guys, I am loading grids using a php file that uses render_table/render_sql. Before the call to render_table I’d like to check the session and if it has expired return an error message to the calling file so that it can redirect to a login page rather than load the grid, what is the best way to do this?

thanks

I had the same problem.

Based on docs.dhtmlx.com/doku.php?id=dhtm … r_response
I’m doing the following:
In the php script which renders the XML data I first check whether the session exists. If not, I pass an error back instead of the rows, like

		header("Content-type: text/xml", true, 401);
		echo "<data>";
		echo "<action type='error'>";
		echo "<![CDATA[\n";
		echo "var message='" . $message . "';";
		echo "\n]]>";
		echo "</action>";
		echo "</data>";

The error handler checks the return status (401):

		dhtmlxError.catchError("LoadXML",function(type,desc,data){
		//data[0] - request object
		//data[0].responseText - incorrect server side response
		if ( data[0].status == 401 ) { // Session expired
				document.location="go somewhere else please";  
		 }
		 return false;
});

works brilliant.

Hi xlthor , thats exactly what I needed, thanks so much for the help!