CodeIgniter Forums

Full Version: session is being expired autometically
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello Guys,

One of my codeigniter Application is not working properly on the server but it's working on my localhost and also working on another VPS server. But not working on my cPanel hosting.

I use wordpress and codeigniter mostly and this session issue is causing only with codeigniter not with wordpress.

I'm using autoload to load session and all others.

Let me know if you guys need any other information

Thanks in advanced.
You should show your session and cookie config. Have you done an isolated session test?
example ur: http://www.domainname.com/temp/welcome/index

when I open it then refresh it.. if session is set then it will show Session working message. then remove the index from url and write about.. it will still show the session working message.

but when I'm clicking on the about hyperlink bellow the message "session working" then session is gone.

here below is the controller code:

PHP Code:
class Welcome extends CI_Controller {

    public function 
index()
    {
     
   if(isset($_SESSION['test_session'])){
     
       echo "session working";
     
   }else{
     
       $this->session->set_userdata('test_session''session set');
     
   }
     
   
        echo 
'<br><a href="'.base_url().'welcome/about'.'">about </a>';
    }
    
    public function 
about()
    {
     
   if(isset($_SESSION['test_session'])){
     
       echo "session working";
     
   }else{
     
       redirect('welcome/index''refresh');
     
   }
    }


I have also attached the cofig folder please check and let me know.. How can I solve the issue.
Have you set your session save path.
Does your host server use the same domain name as your web application?
You also need to tell us what type of sessions you are using, file / database / etc;
Hi,

Thank you so much for replies guys..

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']        = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']     = FALSE;

here is the session config and cokie config

Thanks!!
(09-26-2017, 06:46 PM)shynquynh Wrote: [ -> ]Does your host server use the same domain name as your web application?

yes I'm using the same domain name.
(09-27-2017, 06:38 AM)tysonchamp Wrote: [ -> ]Hi,

Thank you so much for replies guys..

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']        = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']     = FALSE;

here is the session config and cokie config

Thanks!!

Read the in-file documentation above these settings in config.php.
(09-27-2017, 06:38 AM)tysonchamp Wrote: [ -> ]Hi,

Thank you so much for replies guys..

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']        = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']     = FALSE;

here is the session config and cokie config

Thanks!!


You need to set the save path to some thing like this example



PHP Code:
 $config['sess_save_path'] = APPPATH  'cache/sessions/'

Folder permission 0700
Pages: 1 2