Back 2 pages with php / create session of last accessed URL

1

I would like to know how to create a session of the last url accessed, why this: I have a login system on the site that if the person clicks buy in the product and is not logged in, it is directed to the login page, after login, it is redirected to home with a redirect: redirect('/user/painel'); Only that I need that after it logs, she returns to the last url accessed to be able to buy the product that she clicked. Or maybe some header location that goes back two pages. Note: The framework I'm using is Codeigniter I tried to use it too: header("Location: " . $_SERVER['HTTP_REFERER'] . ""); but only one page back, I need you to come back two.

    
asked by anonymous 07.03.2016 / 13:28

1 answer

2

As seen, I used a session:

$_SESSION['url_assine'] = base_url().'assinatura'.$id;
    redirect('erro/efetuar_login_assinatura');

and inside the error controller / effec_login_assinatura I get the session that seveni:

 redirect($_SESSION['url_assine']);
    
08.03.2016 / 15:07