By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,913 Members | 1,356 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

Passing REFERENCE SESSION variables (session number, etc) INTO Frameset

P: 1
I have found I CAN pass variables into FRAMESETS via PHP and SESSION VARIABLES, by doing the following:

in the first file:
Expand|Select|Wrap|Line Numbers
  1. $varname = "variable in question";
  2. $_SESSION['varname'] = $varname;
  3. $substitute_name = $_SESSION['varname'];
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. $_SESSION['varname'] = $substitute_name;
  4. echo "<html>\n";
  5. echo "<FRAMESET cols=200,*>\n";
  6. echo "<FRAME NAME=FRAME1 SRC=/frame1.php></frame>\n";
  7. echo "<FRAME NAME=FRAME2 SRC=/frame2.php></frame>\n";
  8. echo "</frameset>\n";
  9. echo "</html>\n";
  10. ?>
By setting the VARNAME FROM the SUBSITUTED NAME prevents them from interacting and freezing the access, and re-establishes the varname. Do it PRIOR to the HTML declaration, though and it carries into ALL frames.

HOWEVER... you cannot CHANGE it INSIDE a frame, to pass it back, because multiple frames have their OWN instance and changing one does NOT change the other OR the master copy. This only allows establishing PERMANENT REFERENCE variables and passing them INTO the frame.

You MIGHT want to do
Expand|Select|Wrap|Line Numbers
  1. $_SESSION['substitute_name'] = $varname;
as well in the initial declaration just to be sure it gets into the session variables.

Note BOTH files MUST be done with
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  4. pre-declared, ending in
  6. ?>
Which just goes without saying.
Dec 17 '11 #1
Share this Article
Share on Google+