My Model : admin_login_model.php

Unable to view them in browser as shown in the image below


http://i.stack.imgur.com/fychj.png

i am working on CodeIgniter version 3

Can anyone tell me what is the issue

 if ($email === $admin_email && $password = $password) {

            echo 'credential match';

            $this->load->helper('cookie');

            if ($remember_me == '1') {                            

                $email    = $this->input->post('email');
                $password    = $this->input->post('password');
                $remember = $this->input->post('remember_me');

                $cookie1 = array(
                    'name' => 'email',
                    'value' => $email,
                    'expire' => '86400',
                    'domain' => base_url(),
                    'path' => '/admin/',
                    'prefix' => 'myprefix_',
                    'secure' => TRUE

                );

                $this->input->set_cookie($cookie1);
                echo "<pre>";


                var_dump($cookie1);
                echo"</pre>";
                echo 'Checked';
            }

        }
    return TRUE; // if credential matches
    } else {
        return False;
    }

Quoted Text Here

Dani AI

Generated

In ’s example the browser is most likely rejecting the cookie because the attributes sent are invalid for the origin. Setting the cookie’s Domain to the full base_url() (which includes scheme and port) or including a port in Domain will make the Set-Cookie header invalid; likewise marking it Secure while serving over plain HTTP (or restricting Path to a subfolder) can prevent the cookie from appearing where expected. See the Set-Cookie attribute rules. (MDN Set-Cookie header). (developer.mozilla.org) (practical note on ports and localhost behavior). (stackoverflow.com)

CodeIgniter specifics: the CI cookie helper expects an expire value in seconds (or 0 for a session cookie), and the helper simply sends a Set-Cookie header — it won’t magically fix an invalid domain/path/secure combination. For local development omit the Domain attribute (let the cookie be host-only), use Path = '/' unless a narrower scope is required, and set Secure = FALSE when not using HTTPS. Example minimal fix (do not copy the original array verbatim):

$this->load->helper('cookie');

$cookie = array(
  'name'   => 'email',
  'value'  => $this->input->post('email'),
  'expire' => 86400,   // seconds
  'path'   => '/',
  'secure' => FALSE,
  'httponly'=> TRUE
);

$this->input->set_cookie($cookie);

(See CI cookie helper docs for parameter meanings.) (iiti.ac.in)

Quick troubleshooting checklist: confirm the server actually sends a Set-Cookie response header (Network → Response headers), check the Application/Storage → Cookies view in DevTools for the correct domain/path/name, remember cookies set by headers only appear in subsequent requests ($_COOKIE is populated on the next load), and ensure set_cookie() runs before any output or use output buffering/redirects so headers can be sent. PHP’s setcookie notes explain the header/output rules. (php.net setcookie). (php.net)

Recommended Answers

All 2 Replies

Please ask your Question again and in some simple words, you want to ask about cookie storage in your local system or in browser cookies? and also just fail to view or also fail to get result back of that cookie?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.