Help in developing Codeigniter files

Hi to codeigniter, how would I check if the user first visits the site and if they are set to a cookie?

I already use session libraries and database sessions that store session_id, etc., but I need to check if the user is the first visitor and if they already have a cookie `

$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'));`
+5
source share
4 answers

Using the cookie helper, you can check if the user is the first visitor:

if (!get_cookie('some_value')) {
    // cookie not set, first visit

    // create cookie to avoid hitting this case again
    $cookie = array(
        'name'   => 'some_value',
        'value'  => 'The Value',
        'expire' => time()+86500,
        'domain' => '.some-domain.com',
        'path'   => '/',
        'prefix' => '',
    );
    set_cookie($cookie);
}
+14
source

Use Cookie Helper to get / set cookies.

+2
source

, cookie cookie-, , cookie codeignighters $this- > input- > set_cookie setcookie PHP.

I had strange results until I cleared all cookies and reset using my own codeignighters method.

+1
source

fist of everything you need to know the basic idea of ​​a cookie A session is created on a server where a cookie is created in the client browser .

therefore a cookie is created when you view the php file (in which the cookie is set - ter)

And from the next query forward you will get a section to read

0
source

All Articles