...

View Full Version : php conditional referrer event



hedbanger
03-28-2007, 11:37 PM
i have a remote knowledge base application that i call into several different websites. the stylesheet used should depend on the website. i used the referrer to determine which one. but the session doesn't persist once one clicks onto a second page.
an example is at http://www.circulon.com/customer_support_redirect.html
can someone help me tweak my code to get the style to persist?


<? ob_start();

if(!isset($_SESSION['theme_selection'])) {
$_SESSION['theme_selection'] = 'http://www.meyer.com/csenduser.css';
}

if(isset($_SERVER['HTTP_REFERER']) && !strpos(@$_SERVER['HTTP_REFERER'],'meyer.custhelp.com')) {
if(strpos(@$_SERVER['HTTP_REFERER'], 'anolon.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/A.css';
}
else if(strpos(@$_SERVER['HTTP_REFERER'], 'bonjourproducts.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/B.css';
}
else if(strpos(@$_SERVER['HTTP_REFERER'], 'circulon.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/C.css';
}
else if(strpos(@$_SERVER['HTTP_REFERER'], 'kitchenaidcookware.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/K.css';
}
else if(strpos(@$_SERVER['HTTP_REFERER'], 'farberwarecookware.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/F.css';
}

else if(strpos(@$_SERVER['HTTP_REFERER'], 'meyer.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/M.css';
}
else if(strpos(@$_SERVER['HTTP_REFERER'], 'silverstone.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/M.css';
}
else if(strpos(@$_SERVER['HTTP_REFERER'], 'potsandpans.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/P.css';
}
else if(strpos(@$_SERVER['HTTP_REFERER'], 'thepotrack.com') !== false)
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/P.css';
}

else
{
$_SESSION['theme_selection'] = 'http://www.meyer.com/csenduser.css';
}
}
if(isset($_SESSION['theme_selection']))
echo '<link rel="stylesheet" href="'.htmlspecialchars($_SESSION['theme_selection']).'" />';
?>
<? ob_end_flush(); ?>

Krokador
03-29-2007, 05:11 PM
from my knowledge $_SESSION variables require a session_start(); statement on the page so they can persist. Otherwise they'll be set for the current page and will have to be set again for the next.

If I'm wrong feel free to correct me. I'm just trying to help.

hedbanger
03-29-2007, 05:27 PM
thanks krokador,
that sounds reasonable. do you see a way to target the subsequent pages? they're dynamic, but there are a handful of templates that are used that i could specify by name, maybe. there's only the one header that i have access to. is there a way to specify the referrer's referrer? :-}



meantime, i'm going to try taking out that final else statement.
jf

Krokador
03-29-2007, 05:58 PM
I'm trying to think about how you could manage this. I always worked with some kind of global file that had session_start(); as the first statement and was included first thing in all my pages. I imagine your referrer is included in these pages, right? So probably by just adding the session_start(); at the top of your code, it would work.

My head isn't at it's best right now for that kind of thinking, but from what I remember if I didn't put it at the very beggining of my php code, the statement caused an "headers already sent" kind of error. If that doesn't work, then someone else might be better than me in helping you. ^^

hedbanger
03-29-2007, 06:25 PM
thanks again.
i 'm pretty sure that the same header is included in all files. it's just that once a link within the remotely hosted iframe is followed, the domain of the referrer changes. using sessions, or cookies and php or possibly javascript might solve this, but i'm stymied. i'd really like to fix this and hope someone can help me.
jf

hedbanger
04-03-2007, 08:33 PM
i am calling the starting page by using the url after selecting the brand line that i want to display. that is, i use a selection box to search for all of the answers for a particular product line and use that url for the results page that i call into my iframe. a typical example would be:
http://meyer.custhelp.com/cgi-bin/meyer.cfg/php/enduser/std_alp.php?p_sid=MYiaybyi&p_lva=106&p_li=&p_accessibility=0&p_redirect=&p_page=1&p_cv=&p_pv=1.4&p_prods=4&p_cats=0&p_hidden_prods=&prod_lvl1=4&prod_lvl2=0&cat_lvl1=0&p_search_text=&p_new_search=1
however, clicking on one of the search result detail links results in a url that doesn't have the product id. but there is a session id.
http://meyer.custhelp.com/cgi-bin/meyer.cfg/php/enduser/std_adp.php?p_faqid=83&p_created=1049811525&p_sid=MYiaybyi&p_accessibility=0&p_redirect=&p_lva=106&p_sp=cF9zcmNoPTEmcF9zb3J0X2J5PSZwX2dyaWRzb3J0PSZwX3Jvd19jbnQ9NjkmcF9wcm9kcz00JnBfY2F0cz0wJnBfcHY9MS4 0JnBfY3Y9JnBfcGFnZT0x&p_li=&p_topview=1
can i get some help on figuring out how to utilize one of these to continue to access the correct style sheet?
thanks.
jf



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum