Welcome Guest, Not a member yet? Register   Sign In
Session Storage of Google Search URL Fails
#1

[eluser]axiom82[/eluser]
Hello,

Big fan of CI, not a big fan of the session management system right now. I'm trying to store the $_SERVER['HTTP_REFERER'] in the session as user data (in a cookie) like so:


Code:
class Template extends Controller {
    
    function __construct(){

        parent::__construct();
        $this->set_referrer();
        
    }

    function set_referrer(){

        $referrer = $this->session->userdata('referrer');
        if ($referrer === false) $this->session->set_userdata('referrer',$_SERVER['HTTP_REFERER']);

    }

}

The set_referrer() function is called for all controller requests, only the first time it is called should the referrer be set. I have found that with some URL values for my session referrer value, strange behavior emerges with the session class where indeed the value is set multiple times and therefore it changes as different page controllers load.

Here is a Google URL that causes this behavior:
http://www.google.com/url?sa=t&source=we...&q=atlanta georgia personal injury lawyer&ei=Hx30TOPQFcT58AbenPyvDA&usg=AFQjCNESs_1daLcLa2c4HaoUcBMKboU8vA

In the end, I have resorted to this code:

Code:
class Template extends Controller {
    
    function __construct(){

        parent::__construct();
        $this->set_referrer();
        
    }

    function set_referrer(){

        session_start();
        if (!isset($_SESSION['referrer'])) $_SESSION['referrer'] = $_SERVER['HTTP_REFERER'];

    }

}

What gives?


Messages In This Thread
Session Storage of Google Search URL Fails - by El Forum - 11-29-2010, 05:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB