views:

53

answers:

2

Hello again.

I have the following code:

$array = parse_url($_SERVER['HTTP_REFERER']);
$Ur = $array['host'];

which displays the domain just fine, but when I use this with sessions, it doesn't work. Also, I tested it with gettype and it returns Null? I thought it was an array?

Anywho, how do I go about converting the above $Ur into a string?

Cheers!

+3  A: 

Whenever you store or access the sessions, you have to call session_start() before you do or you won't see or be able to access the results later.

If you just want the referrer URL as a string, why not:

$url = $_SERVER['HTTP_REFERER'];

?

cletus
Hi, because I just need the domain value. - Session_start is being called
Keith Donegan
+2  A: 

provide a second component parameter = PHP_URL_HOST to parse_url and it will return a string instead of an array

Scott Evernden
@Evernden, Docs disagree with you.
strager
maybe you thumb-downed before my edit
Scott Evernden
And now I can't undo it. =S
strager
Perfect, thank you!!
Keith Donegan