2

I am trying to develop a registration system.

Registration Info -> Subscription -> Success page

While submitting the user information, I created a session_data and in the Success page controller, I unset the session so that the user cannot go back to the subscription page.

The subscription and success controller is restricted if session data is not set.

Subscription Controller & Success Controller

public function __construct()
{
    parent::__construct();


    if (! $this->session->userdata('st_guid'))
    {
        redirect('register');
    }
}

And in Success Controller Index I unset the userdata.

public function index()
{

    $this->load->view('success');

    // Unset session data
    $this->session->unset_userdata('st_guid');
    $this->session->sess_destroy();
}

Problem is, if I click the browser back button it easily load the subscription page and click the forward button it loads the success page while I already unset the session data. If I refresh the page only then the session data getting destroyed and redirected to registration page.

What should I do ?

I am using Codeigniter 2.2.6

Raja
  • 772
  • 1
  • 15
  • 38
  • try unset the session variable first then load the view. also make sure that you have loaded the session library – Punit Gajjar Sep 06 '16 at 10:30
  • @PunitGajjar Thanks for the comment. I tried it, but the result is same as before. – Raja Sep 06 '16 at 12:28
  • You can find the answer here in this question : [http://stackoverflow.com/questions/10418964/codeigniter-back-button-after-logout](http://stackoverflow.com/questions/10418964/codeigniter-back-button-after-logout) – Punit Gajjar Oct 12 '16 at 14:11

0 Answers0