CodeIgniter Forums
session is being expired autometically - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: session is being expired autometically (/thread-69003.html)

Pages: 1 2


session is being expired autometically - tysonchamp - 09-26-2017

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.


RE: session is being expired autometically - skunkbad - 09-26-2017

You should show your session and cookie config. Have you done an isolated session test?


RE: session is being expired autometically - tysonchamp - 09-26-2017

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.


RE: session is being expired autometically - wolfgang1983 - 09-26-2017

Have you set your session save path.


RE: session is being expired autometically - shynquynh - 09-26-2017

Does your host server use the same domain name as your web application?


RE: session is being expired autometically - InsiteFX - 09-26-2017

You also need to tell us what type of sessions you are using, file / database / etc;


RE: session is being expired autometically - tysonchamp - 09-27-2017

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!!


RE: session is being expired autometically - tysonchamp - 09-27-2017

(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.


RE: session is being expired autometically - Narf - 09-27-2017

(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.


RE: session is being expired autometically - wolfgang1983 - 09-27-2017

(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