Timothy Trisnadhama Timothy Trisnadhama - 1 year ago 79
PHP Question

$_SESSION, PHP, iframe, not getting the SESSION variables

I m creating a very simple PHP-based program for warehousing but quite complicated back-end process.

So here is the situation:

  1. I have the login page that directs to authorization page where it set the
    for the first time,
    and set the session variables.

  2. After the authorization page, it goes to the main.php page that is a table with left hand side for menu (links) that I also did
    <-- same name as the one created from (1), and start the session.

  3. On the right hand side of the main page is the iframe that display the page when user click the links on the left. I also did
    <-- same name as the one created from (1), and start the session.


main.php is ok, it reads the session variable perfectly, but the iframe couldn't get the session variables (i tried to
, and came up empty). I tried
, where "abc" is the session name that i used in (1), and it does show "abc", tried (
) and returns true... so I don't know what am I doing wrong...

I m sorry guys, i think i may have found the culprit... it is a logic error on my side... i have this condition to check every php page i created to destroy session when the user level is not authorized to use this current page. My bad.. thanks so much for your help guys!!

Lan Lan
Answer Source

Make sure that session_start() is on all the pages:

session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.

see PHP manual reference

To control the contents of the $_SESSION try to put in all ifreame pages the code:


   echo '<pre>';
   echo '</pre>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download