php - session is not working in new server


I moved my code-igniter project to new server but session is not working across other page but in same page controller function is like

public function login()
    $typo = "teacher";
    $co=array('ededge_typo' => $typo);

in view

<?php var_dump($this->session->userdata('ededge_typo'))); ?>

but i get output Null

when i tried in localhost i get

C:\wamp\www\cii\application\views\header.php:1:string 'Teacher' (length=7)

please help me to

my configuration in codeigniter is

$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['time_reference'] = 'gmt';



Have you tried to print session by print_r($_SESSION) on your view page. Print it, if your session is set it will show you.




Use database session

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





$config['sess_driver'] = 'files';
$config['sess_save_path'] = '/var/www/html/my_app/tmp/';

From codeigniter documentation:

'sess_save_path' | | The location to save sessions to, driver dependent. | | For the 'files' driver, it's a path to a writable directory. | WARNING: Only absolute paths are supported! | | For the 'database' driver, it's a table name. | Please read up the manual for the format with other session drivers. | | IMPORTANT: You are REQUIRED to set a valid save path!

If you dont want to change that folder manually every time when you change server, you could try something like

$config['sess_save_path'] = FCPATH . 'tmp/';
$config['sess_save_path'] = BASEPATH . 'tmp/';

The fcpath one should be xxx/my_app/tmp and basepath should be xxx/my_app/application/tmp

Both folders should be writeable.

People are also looking for solutions to the problem: javascript - Populate second input text based on previous one


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.