alex
2013-01-24 18:06:17 UTC
<?php // pagina1.php
header("Location: pagina2.php");
?>
<?php // pagina2.php
echo "L'url della pagina precedente è " . $_SERVER['HTTP_REFERER'];
?>
Quindi mi collego a
http://sito/pagina1.php
ma non funziona...
Notice: Undefined index: HTTP_REFERER in .../pagina2.php on line 2
Il manuale l'ho letto
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to
the current page. This is set by the user agent. Not all user agents
will set this, and some provide the ability to modify HTTP_REFERER as a
feature. In short, it cannot really be trusted.
'HTTP_USER_AGENT'
Contents of the User-Agent: header from the current request, if
there is one. This is a string denoting the user agent being which is
accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U;
Linux 2.2.9 i586). Among other things, you can use this value with
get_browser() to tailor your page's output to the capabilities of the
user agent.
Cmq una cosa l'ho capita: se si apre pagina1.php, cliccando su un link
che naturalmente punta ad essa, e tale link è contenuto in una pagina
(pagina0.php) che fa parte dello stesso sito, il sistema funziona
perfettamente.
Infatti compare:
http://sito/pagina0.php
Quindi in pratica la cosa non funziona solo se si fa il redirect:
header("Location: pagina2.php");
Come mai?
header("Location: pagina2.php");
?>
<?php // pagina2.php
echo "L'url della pagina precedente è " . $_SERVER['HTTP_REFERER'];
?>
Quindi mi collego a
http://sito/pagina1.php
ma non funziona...
Notice: Undefined index: HTTP_REFERER in .../pagina2.php on line 2
Il manuale l'ho letto
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to
the current page. This is set by the user agent. Not all user agents
will set this, and some provide the ability to modify HTTP_REFERER as a
feature. In short, it cannot really be trusted.
'HTTP_USER_AGENT'
Contents of the User-Agent: header from the current request, if
there is one. This is a string denoting the user agent being which is
accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U;
Linux 2.2.9 i586). Among other things, you can use this value with
get_browser() to tailor your page's output to the capabilities of the
user agent.
Cmq una cosa l'ho capita: se si apre pagina1.php, cliccando su un link
che naturalmente punta ad essa, e tale link è contenuto in una pagina
(pagina0.php) che fa parte dello stesso sito, il sistema funziona
perfettamente.
Infatti compare:
http://sito/pagina0.php
Quindi in pratica la cosa non funziona solo se si fa il redirect:
header("Location: pagina2.php");
Come mai?