Welcome Guest, Not a member yet? Register   Sign In
Check whether it is users first visit
#1

[eluser]sico87[/eluser]
Hello in codeigniter how would I check if the user is visiting the site for the first time, and if they are set a cookie?

I am already using the Session library and database sessions which stores the session_id etc, but I need to to be able to check if the user is a first time visitor and if they have a cookie already

Code:
$cookie = array(
                           'name'   => 'some_value',
                           'value'  => 'The Value',
                           'expire' => time()+86500,
                           'domain' => '.some-domain.com',
                           'path'   => '/',
                           'prefix' => '',
                       );

        set_cookie($cookie);
        var_dump(get_cookie('some_value'));

Above is the code I currently have
#2

[eluser]Ian Jones[/eluser]
You can simply check if the cookie exists. If it doesn't then it means they are new, so set a non-expiring cookie and pray they don't clear their cookies.




Theme © iAndrew 2016 - Forum software by © MyBB