Jump to content

stuck with what to do


EchoFool

Recommended Posts

Hey,

 

I'm in an annoying situation where i cannot think what to do in order to solve my issue so hopefully someone here may have a solution.

 

Currently my site can be viewed on an external site with my site withing an iframe.

 

Now what i have is this on the file on my server:

<?php
require_once 'library/client/library.php';
session_start();
$_SESSION['Var'] = 1;
?>
<iframe src ="http://www.domain.com" width="630" height="600" style="overflow-x: hidden;">
</iframe>
?>

 

This is working perfectly but when $_SESSION['Var'] is set, a different CSS file is loaded so that the site loads and fits in the iframe perfectly.

 

Now if a user leaves the site with the iframe and visits the main site normally, the $_SESSION['Var'] is still set and thus it loads the wrong layout. Is there a way I can check when the following situation occurs:

 

if user views www.domain.com via iframe on secondary site

if user views www.domain.com normally on browser

 

That way i can unset $_SESSION['Var'] if its the latter.

Perhaps theres a way in php to check if the site is in an iframe ?

 

Any thoughts that may help is much appreciated.

Link to comment
Share on other sites

why not check the HTTP_HOST then set the session variable accordingly.

 

<?php
if($_SERVER['HTTP_HOST'] != "www.domain.com"){
$_SESSION['Var'] = 1;
} else {
$_SESSION['Var'] = 0;
}
?>

 

I am not sure what you code is like but something like above should work.

 

Ray

Link to comment
Share on other sites

Im afraid that didnt work. The application is from facebook which is calling my file which contains the script shown above... so that script is actually on my site, but facebook loads it into their application so everyone in essence is hosted on my server and loaded from it.

 

So the only way to solve it is possibly some way to know if my site is being loaded in an iframe rather than a normal browser window? If thats even possible server side?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.