• Iam trying wp_get_referer, in the address localhost/myproject/#anchor but there’s nothing coming from it.

    There’s the dump of my $_SERVER variable:

    Array ( [HTTP_HOST] => 192.168.0.1 [HTTP_USER_AGENT] => Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip,deflate [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [HTTP_KEEP_ALIVE] => 300 [HTTP_CONNECTION] => keep-alive [HTTP_COOKIE] => wp-settings-1=; wp-settings-time-1=1266243738; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_b103e7ba5b710aa7fefc34c705319116=admin%7C1266457273%7C4096c696d09e07878fbef506595ae02e; qtrans_cookie_test=qTranslate+Cookie+Test; qtrans_cookie_test=qTranslate+Cookie+Test; wordpress_logged_in_7457ad6173; wordpress_test_cookie=WP+Cookie+check [HTTP_IF_MODIFIED_SINCE] => Tue, 16 Feb 2010 16:29:56 GMT [PATH] => /usr/local/bin:/usr/bin:/bin [SERVER_SIGNATURE] =>
    Apache/2.2.12 (Ubuntu) Server at 189192.1680.01 Port 80
    [SERVER_SOFTWARE] => Apache/2.2.12 (Ubuntu) [SERVER_NAME] => 192.168.0.1 [SERVER_ADDR] => 192.168.0.1 [SERVER_PORT] => 80 [REMOTE_ADDR] => 192.168.0.1 [DOCUMENT_ROOT] => /var/sites [SERVER_ADMIN] => webmaster@localhost [SCRIPT_FILENAME] => /var/sites/project/index.php [REMOTE_PORT] => 58450 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /project/ [SCRIPT_NAME] => /project/index.php [PHP_SELF] => /project/index.php [REQUEST_TIME] => 1266338079 [argv] => Array ( ) [argc] => 0 ) 1

    there’s something wrong?

Viewing 1 replies (of 1 total)
  • What makes you think the data will be in the $_SERVER array?

    Perhaps try something like..

    $my_referrer = wp_get_referer();
    if( $my_referrer ) {
    	echo 'The referrer is: ' . $my_referrer;
    }

    Here’s a copy of the function so you can see how it works..

    function wp_get_referer() {
    	$ref = '';
    	if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
    		$ref = $_REQUEST['_wp_http_referer'];
    	else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
    		$ref = $_SERVER['HTTP_REFERER'];
    
    	if ( $ref !== $_SERVER['REQUEST_URI'] )
    		return $ref;
    	return false;
    }

    from wp-includes/functions.php.

Viewing 1 replies (of 1 total)
  • The topic ‘why my wp_get_referer returns empty?’ is closed to new replies.