CodeIgniter Forums

Full Version: Upgrade 2.0.2 to 3.1.10 session problem on local mamp
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm updating my Codeigniter. I've deleted de system folder and replaced it with the new one. I've followed the Upgrading from 2.2.x to 3.0.x instructions. These are my new settings for the session:

I use autoload for the Session.

$config['sess_driver'] = 'files';

$config['sess_cookie_name'] = 'ci_session';

$config['sess_expiration'] = 0;

$config['sess_save_path'] = APPPATH.'/sessions';

$config['sess_match_ip'] = FALSE;

$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;

I use: 
      $newdata = array(

        'username'  => $member->email,

        'owner_id'  => $member->member_id,

        'logged_in' => TRUE

      );


      $CI->session->set_userdata($newdata);

[font=Arial,] can print username, owner_id after the set_userdata, but when I redirect to the default page in my admin, I get $_SESSION empty
[/font]

(except for the __ci_last_regenerate )

The folder is "OK"(I can see the new session).
[font=Arial,]I'm using MAMP PRO 5.3 with on port 8890 for ssl. I've tried database driver with same results.[/font]

[font=Arial,][font=Arial,]I've tried PHP 7.1.26, 7.0.33, 5.6, 7.3.3[/font][/font]

[font=Arial,][font=Arial,]Thanks[/font][/font]
What are your cookie $config settings?

I'm asking about this set of config items.
PHP Code:
$config['cookie_prefix'
$config['cookie_domain'
$config['cookie_path']
$config['cookie_secure']
$config['cookie_httponly'

They must also be set correctly.

You must have permissions and ownership set appropriately for APPPATH.'/sessions'; too.
(04-12-2019, 03:52 PM)dave friend Wrote: [ -> ]What are your cookie $config settings?

I'm asking about this set of config items.
PHP Code:
$config['cookie_prefix'
$config['cookie_domain'
$config['cookie_path']
$config['cookie_secure']
$config['cookie_httponly'

They must also be set correctly.

You must have permissions and ownership set appropriately for APPPATH.'/sessions'; too.


Here's my settings:

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

I've tried with domain and a lot more different configuration. 
Thanks
(04-13-2019, 05:07 AM)defos931 Wrote: [ -> ]Here's my settings:

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

I've tried with domain and a lot more different configuration. 
Thanks

Did you try this for the domain?

PHP Code:
$config['cookie_domain']    ".example.com"

Note the period (.) before the domain.

While it should not make a difference I suggest using the following config item until you get everything else working.

PHP Code:
$config['sess_regenerate_destroy'] = FALSE
Update:

the config is good because I can trick something to get the session working. But, when I logged a new session is created, then I redirect and validate in the redirectController if I'm logged, but then the session_id change.

I've a library Authentification that I autoload. I do in the constructor : $this->CI =& get_instance();

It's like when I redirect, I get a new session and the weird thing is when I redirect for a second time(because where're not logged in) the session is ok.
Thanks for any help
The session cannot be said to be working when you set session data and then, after a redirect, cannot find that saved data in $_SESSION.

Your problem might be the configuration or it might be the Authentication library implementation. What you describe has been traced to configuration problems time and time again.

Maybe if you examine cookie creation and which cookies are being transferred to/from the browser/server it will help you confirm that the cookie config is good. It may not be the problem. In which case it is probably custom code implementation.