Welcome Guest, Not a member yet? Register   Sign In
Assign promocode, but only if cookies are accepted
#4

[eluser]Ian Jones[/eluser]
Code:
if($this->session->userdata('cookies_enabled'))
{
    if($this->session->userdata('promo_code') == '123456')
    {
        // Found a matching promo, user is valid
    }
    else
    {
        // No promo assigned, so assign one
        $userData = array('promo_code' => '123456');
        $this->session->set_userdata($userData);
        redirect('home', 'refresh');
    }
}
else
{
    // No cookie, set a cookie
    $userData = array('cookies_enabled' => True);
    $this->session->set_userdata($userData);
    redirect('home', 'refresh');
}


Sure it means redirects, but at least the user doesn't need to click. Remember you could actually send the cookie with an HTTP header rather than a full page refresh.

You could also make a system which just uses the clients IP and assigns that IP a unique promo code. Then you just check the database to match the IP to the promo code


Messages In This Thread
Assign promocode, but only if cookies are accepted - by El Forum - 01-19-2010, 08:40 AM
Assign promocode, but only if cookies are accepted - by El Forum - 01-19-2010, 09:03 AM
Assign promocode, but only if cookies are accepted - by El Forum - 01-19-2010, 09:08 AM
Assign promocode, but only if cookies are accepted - by El Forum - 01-19-2010, 09:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB