Search the Community
Showing results for tags 'Session $_Session'.
Hello. I'd just like to enquire about using session S_session please. I've created 4 sessions to hold the log in data for the access to a database (host, username, password, database name) At present I've got it to load this data from a file and insert it into a session. Then for my use I've got it to display this data, to ensure it's reading from the file - which it is doing correctly. The problem I've got is in another php file. In the other php file the sessions are all blank and I don't know why this is. ---- In my index.php file the code reads [this works]:- //ReadFile $fp = fopen( dirname(__FILE__).'/Core/sys/dbinfo.txt', 'r' ) or die("Couldn't open file:- 1"); $db_host = fgets($fp); $db_user = fgets($fp); $db_pass = fgets($fp); $db_databasename = fgets($fp); fclose( $fp ); $_SESSION['dbf_host'] = $db_host; $_SESSION['dbf_user'] = $db_user; $_SESSION['dbf_pass'] = $db_pass; $_SESSION['dbf_databasename'] = $db_databasename; and in the other php file, the code reads:- session_start(); echo "new php file\n"; echo $_SESSION['dbf_host']; echo $_SESSION['dbf_user']; echo $_SESSION['dbf_pass']; echo $_SESSION['dbf_databasename']; The above code produces a blank screen. Could anyone please advise me? Thank You.