Jump to content
deserty

$_server['http_referer'];

Recommended Posts

Exemplu :


<?php
$referer = $_SERVER['HTTP_REFERER'];
if (preg_match("/pagina100/",$referer))
{
echo "vizita a venit din pagina100";
}

elseif (preg_match("/pagina200/",$referer))
{
echo "vizita a venit din pagina200";
}

else
{
echo "vizita fara referer";
}
?>

Pe chrome functioneaza perfect. Insa pe Mozilla nu.

Testat pe mai multe calculatoare si la fel face.

Link to comment
Share on other sites

<?php

session_start();

if(isset($_SESSION['ref']) && !empty($_SESSION['ref']))
{
if(preg_match("/pagina200/",$referer))
echo "se pare ca a venit de pe pagina 200";
elseif(preg_match("/pagina100/",$referer))
echo "se pare ca a venit de pe pagina 100";
}
else
echo "se pare ca a venit din padure";

$_SESSION['ref'] = $_SERVER['REQUEST_URI'];

?>

Prima solutie ce mi-a venit in cap :)

//Modificare: Problema e, din cate imi aduc eu aminte, ca "HTTP_REFERER" nu este trimis de toate cotrobaitoarele de internet, deci nu este bine sa-l folosesti.

//Modificare2: Am gasit si pe http://php.net/manual/en/reserved.variables.server.php , "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."

Deci, cum ziceam, mai bine nu-l folosesti.

Edited by BogdanNBV
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...