I'm not an php expert. I'm working on some php application and need help regarding php sessions or possibly something else.

description application1:

On the apache server I have 1 php application/domain hosted in vhosts environment. Application has some protected pages and bulit in authentication logic, asks for username and password, retrives from mysql ans stores data into sessions. Application is hosted as virtual dir, it has its own domain1.com - This application is working fine, everything is ok.

application2:

On the same aoache/php server, as a vhost is hosted 2nd application, it has it's own domain2.com. It has the same builtin logic, but I expirience some wierd problems with sessions.Sessions values are lost once I call header("location: some_page.php"); , or if I refresh the same page - so for example once user logs in, if page is refreshed, session value user_id is lost and user is logged out.

On every page, i 1st call the same sec_session_start() function, the same i use in Apllication1 which is working fine, but only with altered $session_name = 'sms_sess_sid' variable:

function sec_session_start() { $session_name = 'sms_sess_sid'; // Set a custom session name $secure = false; // Set to true if using https. $httponly = true; // This stops javascript being able to access the session id.