php - session not working between pages of different directories -


i had been working on issue since last 2 days, still unable solve.

i had 2 script 1 in root directory session registered , remain persistent when access page again, when going access page sub directory script suggest no session registered.

detail explanation below :

problem when start_session() root directory script : http://www.kstreethome.com/test.php it's working fine

code /test.php

<?php  error_reporting(e_all);  echo "this session save path : " . session_save_path() . "</br>"; //echo phpinfo();     if(!isset($_session['user']))     {         echo "session not set </br>";                     session_start();                     $_session['user'] = "hiren";                     $_session['accesstype'] = "u";                     $_session['usertype'] = "w";                     $_session['userid'] = "123";                     $_session['datauser'] = "test";                     $_session['password'] = "test";          echo session_id();          echo $_session['user'];         echo $_session['accesstype'];         echo $_session['usertype'];         echo $_session['userid'];         echo $_session['datauser'];         echo $_session['password'];          }     else     {     echo "session set </br>";              echo $_session['user'];         echo $_session['accesstype'];         echo $_session['usertype'];         echo $_session['userid'];         echo $_session['datauser'];         echo $_session['password'];         }   ?> 

but

when start_session() sub directory ajax script : http://www.kstreethome.com/ajax/test.php it's not working in script storing session , accessible in same run when reload /ajax/test.php session destroyed , have start again.

code /ajax/test.php

<?php  error_reporting(e_all);  echo "this session save path : " . session_save_path() . "</br>"; //echo phpinfo();     if(!isset($_session['user']))     {         echo "session not set </br>";                     session_start();                     $_session['user'] = "hiren";                     $_session['accesstype'] = "u";                     $_session['usertype'] = "w";                     $_session['userid'] = "123";                     $_session['datauser'] = "test";                     $_session['password'] = "test";          echo session_id();          echo $_session['user'];         echo $_session['accesstype'];         echo $_session['usertype'];         echo $_session['userid'];         echo $_session['datauser'];         echo $_session['password'];          }     else     {     echo "session set </br>";              echo $_session['user'];         echo $_session['accesstype'];         echo $_session['usertype'];         echo $_session['userid'];         echo $_session['datauser'];         echo $_session['password'];         }   ?> 

the code same in both file , it's testing purpose

another strange thing in root script /test.php says session path '' default null had not changed defaults inn php.ini, in script /ajax/test.php says session save path /tmp strange right?

it needless works fine local server not on hosting server please guide me in issue.

put session_start() @ top of every page

<?php  session_start();  error_reporting(e_all); 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -