Link to home
Start Free TrialLog in
Avatar of MDauphinais1
MDauphinais1

asked on

Remember Sessions Within FRAMESETS

I'm having trouble with sessions being read in a frameset.

I have a site mydomain.com where the user logs in, a cookie is created and everything works great.  Some of my pages are required to be launched from anotherdomain.com due to licensing regulations. So on the anotherdomain.com site I have some HTML files with FRAMESETS that include the PHP files from mydomain.com. When you launch these HTML files from the anotherdomain.com site the browser doesn't remember you logged in already. How can I fix this?
Avatar of karlwilbur
karlwilbur

If you know that you'll be in a frame, you could use javascript to search the parent window for its cookies. Or you could pass the PHPSESSID in a POST or GET variable rather than rely on COOKIE.

By the nature of cookies, you will not see cookies for anotherdomain.tld when your domain is mydomain.tld
Avatar of MDauphinais1

ASKER

Since I am going from my PHP site, out to an .html URL and then FRAMESETing my PHP site again, how can I pass the PHPSESSID all the way through? Is it possible to post the PHPSESSID from the original PHP file to the HTML file and then grab it from the HTML file and attach it to the FRAMESET?
<frameset>
         <frame src="frame1.php?PHPSESSID=<?=session_id()?>" name="frame1">
         <frame src="frame2.php?PHPSESSID=<?=session_id()?>" name="frame2">
</frameset>
Actually, this is better:

<frameset>
         <frame src="frame1.php?<?=session_name()?>=<?=session_id()?>" name="frame1">
         <frame src="frame2.php?<?=session_name()?>=<?=session_id()?>" name="frame2">
</frameset>
Not sure how I would use that... Here's what's happening.  

The main site  mydomain.com  has a regular link that goes to   http://anotherdomain.com/folder/folder/myfolder/page.html

In the page.html file I have the FRAMESET:
<FRAMESET COLS="100%">
<FRAME SRC="http://mydomain.com/somepage.php">
</FRAMESET>

So can I somehow grab the session id on the first page, send it to the html page, and then grab it from the html page and attach it to the php file name in the FRAMESET?

First page link:    "http://anotherdomain.com/folder/folder/myfolder/page.html?PHPSESSID=jBA9938FNSKSA92"

Page.html file:  
get PHPSESSID;

<FRAMESET COLS="100%">
<FRAME SRC="http://mydomain.com/somepage.php?PHPSESSID=jBA9938FNSKSA92">
</FRAMESET>

I think passing the session id to the HTML file through the address bar and grabing it again like you can do with PHP is my biggest problem...
ASKER CERTIFIED SOLUTION
Avatar of karlwilbur
karlwilbur

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!  Thank you.
Glad I could help.