I use sessions for PHP login systems. In all login examples, people directly use the " session_start() " function. But I was embarrassed about it.
===============================================
On localhost, I have these files;
http: //localhost/app1/page1.php
http: //localhost/app1/page2.php
http: //localhost/app2/page2.php
===============================================
In app1/page1.php I start a session and set a variable.
session_start(); session_regenerate_id( true ); $_SESSION[ 'name' ] = 'this is my name';
===============================================
In app1/page2.php and app2/page2.php I start a session and get the value of this variable.
session_start(); echo 'name: ' . $_SESSION[ 'name' ];
===============================================
I open http: //localhost/app1/page1.php and then http: //localhost/app1/page2.php and it works fine. But after that I open http: //localhost/app2/page2.php and also shows "this is my name" on the screen, and this is wrong. Because it is a different application, and I do not want application2 to reach app1 session.
How can I solve this problem? I do not want to use different variable names for each application. I think there must be another good solution. I can restore the ID on app2 / page1.php, perhaps, but if a person tries to open app2 / page2.php, after opening app1 they can get into application2, and this will not be good for me.
Thanks.