Welcome Guest, Not a member yet? Register   Sign In
All about Ajax!
#3

[eluser]Pascal Kriete[/eluser]
Whoops, missed the authentication part. I don't change anything except for the response.

Basically, my auth lib would look like this:
Code:
// asnyc_request() is defined in a helper
if ( ! $this->CI->session->userdata('logged_in') )
{
    if (async_request())
    {
        $this->output->set_status_header('401');
        echo json_encode(array('redirect' => site_url('login'));
        exit;
    }
    redirect(site_url('login'));
}
The javascript checks the header and acts accordingly. In this case it will redirect to the url in the response.


Messages In This Thread
All about Ajax! - by El Forum - 10-03-2008, 07:48 PM
All about Ajax! - by El Forum - 10-03-2008, 08:18 PM
All about Ajax! - by El Forum - 10-03-2008, 08:27 PM
All about Ajax! - by El Forum - 10-04-2008, 02:27 AM
All about Ajax! - by El Forum - 10-04-2008, 02:53 AM
All about Ajax! - by El Forum - 10-04-2008, 04:16 AM
All about Ajax! - by El Forum - 10-07-2008, 02:16 PM
All about Ajax! - by El Forum - 10-07-2008, 06:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB