0

Hi guys,

I am still kind of struggeling with my upgrade from php4 to php5, my site is almost there but I can't figure out how to set my http_referer.

This is how it looks like today:

<?php
 $_SESSION["referer"] .= $_SERVER['HTTP_REFERER'];
 $my_web = $_SESSION["referer"]
?>

The error message I get is "undefined variable: _SESSION and undefined index: referer".

I have tried to put isset() everywhere, but I can not figure out the soulution.

Any suggestions? :)

2
Contributors
6
Replies
12
Views
5 Years
Discussion Span
Last Post by Ingska
0

Your script should be the following:

<?php session_start();
 $_SESSION["referer"] .= $_SERVER['HTTP_REFERER'];
 $my_web = $_SESSION["referer"]
?>

Also you will need to find another alternative to $_SERVER as it isn't always that accurate. The reason being is users can disable that information being sent.

0

Thanks for the suggestion, but it still doesn't work. I still get the same undefined variable/index errors :(

0

Ow now I see. Another bug. Try this.

<?php session_start();
if (!isset($_SESSION['referer']) { 
    $_SESSION['referer']='';
    }
$_SESSION['referer'].=$_SERVER['HTTP_REFERER']."\n";
$my_web = $_SESSION['referer']
?>
0

I think it's something along these lines i need. But now i got an error saying "unexpexted '{' in line 2". When i take the '{' away, obviously I get an other error. I also tried to mix up the code a little, but i still can't get it right.

0

OMG these bugs keep on coming. Did you hide any more for me to fix?

<?php session_start();
if (!isset($_SESSION['referer'])) { 
    $_SESSION['referer']='';
    }
$_SESSION['referer'].=(isset($_SERVER['HTTP_REFERER']))?($_SERVER['HTTP_REFERER']."\n"):'';
$my_web = $_SESSION['referer'];
?>

This time I tested it :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.