0

I am new to codeigniter framework. I am trying to build a authentication system.

Authentication is working fine. My problem is that after successfully logging, when I click the back button in the browser it is directed to login page again. I want to redirect it to the home page itself. i want to reload the home page not the index page(index page is the login page, after successful login goes to home page)

How can I do it

Sonali
  • 1
  • 2
  • With out some code bit hard to help you. You can re edit your question by clicking on edit button below tags –  Feb 23 '17 at 07:14

2 Answers2

0

In your login page check that login session is started or not, if it is started than redirect to home page :

if(isset($_SESSION['user']))
{
    header('Location:http://localhost/projectname/home');   
}

If you have any confusion please let me inform. Thanks

0

on the home page controller check whether the session exists or not. if it exists then redirect to home page otherwise login page.

In your home_model.php do something like below:

<?php

class Home_model extends CI_Model
{
    function __construct()
    {
        parent::__construct();
        $this->check_session();
    }

    function check_session()
    {
        $session_login = $this->session->userdata("MYLOGIN");
        if($session_login == '')
        {
            redirect('home');
        }
        if($session_login == 1 && $session_login == TRUE)
        {
            redirect('home/dashboard');
        }
    }
}

Load home_model in home controller.

Pathik Vejani
  • 4,263
  • 8
  • 57
  • 98