0

So I recently clean installed Windows 10 on my laptop and began setting up my dev environment. I am currently working on 2 PHP applications built on top of Codeigniter, one is hosted in local XAMPP install and the other uses vagrant to provision a centos 7 VM with Apache, MySQL, PHP, Redis etc. The site running on local XAMPP install is accessable via http://localhost and the other is accessed through a domain setup in the hosts file to route the domain to the IP of the VM.

Here comes the issues, I can access both sites and everything appears to work as intended until I go to login to the sites and begin to use session data. For example, in the $_SESSION array I store login data and every time I login the data gets set but doesn't persist to the next page load.

Both these applications work without issue in the production environment and on other development machines. Same behaviour using Chrome, Firefox & Edge.

I am honestly stumped as to what the issue could be and could use a little help or even a hint as to where I should be looking.

Thanks in advance!

wilson208
  • 346
  • 2
  • 7
  • Wait - so BOTH the setups doesn't retain session-data? On two different setups/servers, with different paths to the session-storage? – junkfoodjunkie Apr 22 '17 at 00:04
  • Put `session_start()` at the top of any `$_SESSION` pages before any headers are sent. – StackSlave Apr 22 '17 at 00:07
  • @junkfoodjunkie thats right, identical setup to my other windows box where it is working perfectly, also working without issue on my graphic designers macbook pro. – wilson208 Apr 22 '17 at 00:16
  • @PHPglue Both applications are using the Codeigniter Session helper class and working without issue on other machines. This issue is something to do with my machine setup and I don't know what. – wilson208 Apr 22 '17 at 00:16
  • Well, can you see the session-data on the disk when you initiate the session? And what happens to that data when you load other pages? – junkfoodjunkie Apr 22 '17 at 00:20
  • Did you set your session path on config.php `$config['sess_save_path'] = APPPATH . 'core/session/';` –  Apr 22 '17 at 00:37
  • This is usually bad session config setting and/or cookie config. Care to share you configs? – DFriend Apr 22 '17 at 01:51
  • About the CI session problem in PHP7, you can solve by this: https://stackoverflow.com/a/56355732/3929170 – Leon Lo May 30 '19 at 01:27

1 Answers1

0

This turned out to be a Codeigniter issue with PHP 7.1. It was fixed in a minor version bump a few versions behind the version I was on. Thanks for everyones suggestions. I was using vagrant and for some reason on one of my machines, the vagrant box was installing PHP 5.6 and the other it was installing 7.1, and this is where the session issues were arising.

wilson208
  • 346
  • 2
  • 7