Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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'];

?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top