0

The Problem is when I logged-in in my admin and go to other view forms from my admin and click back or go back the browser will display an error. and it says "Document Expired".

This is the Controller:

public function validate()  
  {  
       $this->load->library('form_validation');  
       $this->form_validation->set_rules('user', 'Username', 'required');  
       $this->form_validation->set_rules('pass', 'Password', 'required');  
       if($this->form_validation->run())  
       {  

            //true  
            $username = $this->input->post('user');  
            $password = $this->input->post('pass');  

            //model function  
            $this->load->model('add_mod');  

            $query = $this->add_mod->can_login($username, $password);

            $session_data = array(  

                'id' => $query['id'],
                'user' => $query['user']

             );  


             $this->session->set_userdata($session_data);  

            if($query)  

            {  


                $data['title'] = "Welcome ". $query['user'];

                $this->load->view('templates/header', $data);
                $this->load->view('admin/home', $data);
                $this->load->view('templates/footer', $data);

            }  

            else  
            {  
                 $this->session->set_flashdata('error', 'Invalid Username and Password');  
                 redirect(base_url() . 'admin/login');  
            }  
       }  
       else  
       {  
            //false  
            $this->login();  
       }  
  }

This is the model

        public function can_login($username, $password)  
          {  
               $this->db->where('user', $username);  
               $this->db->where('pass', $password);  
               $query = $this->db->get('accounts');  

               if($query->num_rows() > 0)
               {  
                    return $query->row_array();
               }  
               else  
               {  
                    return false;       
               }  
          }

That's mostly my problem and stackoverflow won't let me post this because its mostly code here thanks in advance. More power from Philippines

3
  • 1
    I thing you are using POST method. Try with GET method. Commented Feb 24, 2018 at 8:55
  • Uhmm I tried it but still getting the same result, but thank you tho Commented Feb 24, 2018 at 9:00
  • Check my answer and see if it solves your problem. Commented Feb 24, 2018 at 9:13

1 Answer 1

1

Here, add this at the start of the PHP code:

<?php
ini_set('session.cache_limiter','public');
session_cache_limiter(false);
?>

Or set Cache-Control header in your main page.

<?php
header('Cache-Control: max-age=900');
?>
Sign up to request clarification or add additional context in comments.

1 Comment

You're welcome. Please upvote the answer. Have a great day.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.