CodeIgniter Forums
Sessions not playing nice with homerolled PHP site - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Sessions not playing nice with homerolled PHP site (/showthread.php?tid=91069)



Sessions not playing nice with homerolled PHP site - eLRobbo - 06-12-2024

Hi  y'all,

I have an existing site that was written without using codeigniter using php5.  Yes, we know that we have to upgrade, hence the new codeigniter site.  The current site is huge, and will take months (if not years) to port over to the new codeigniter site.  So, in the meantime, we need to use sessions to maintain a user's status between the two sites, but it is not working.
The sessions are being saved to the same location on the server (for the purposes of this discussion - localhost).  The sites are subdomains, so there should be no issue sharing the session, however I must have an incorrect setting somewhere in codeigniter.  I have verified the non-codeigniter sites by making two different subdomains and sharing sessions between them, so that's not the issue.
In the actual folder where the sessions are stored, the standard php sites save the session as sess_xxx (where xxx is the session id).  The session name is the default PHPSESSID.
When I run codeigniter, it creates a new/separate session using the same session id but as PHPSESSID_xxx (where xxx is the same as the original session id).

in app/config/Cookie
public string $prefix = '';
public bool $secure = false;

in app/config/Session
public string $cookieName = 'PHPSESSID';

Any help?


RE: Sessions not playing nice with homerolled PHP site - kenjis - 06-12-2024

You cannot change the session filenames ({SessionName}_xxx) unless you customize CI4 Session class.