Welcome Guest, Not a member yet? Register   Sign In
Cookie not working in codeigniter 4. Need helper
#3

(04-19-2020, 02:12 PM)Leo Wrote: Hi, can you post your code? Some guy on the forum was trying to set a cookie with a negative timestamp.


Here is the my code for setting the cookie
if ($remember === 1) {
           
            set_cookie(array(
                'name' => getConfig('auth_cookie_id'),
                'value' => $this->_user->enc_key,
                'expire' => \time() + getConfig('auth_cookie_expiry'),
                'httponly' => FALSE
            ));

            // store encrypted key in cookie
            set_cookie(array(
                'name' => getConfig('auth_cookie_key'),
                'value' => $enkey,
                'expire' => \time() + getConfig('auth_cookie_expiry'),
                'httponly' => FALSE
            ));
        } else {
            // set what will be stored in the session
            $data = array(
                getConfig('auth_session_id') => $this->_user->enc_key,
                getConfig('auth_session_key') => $enkey
            );

            // store data in the session
            session()->set($data);
        }


Here, is where i try to get the cookie data
if (get_cookie(getConfig('auth_cookie_id'), TRUE) && get_cookie(getConfig('auth_cookie_key'), TRUE)) {
            // store cookie informations in variables
            $encryptedUserIDs = get_cookie(getConfig('auth_cookie_id'), TRUE);
            echo $enckey = get_cookie(getConfig('auth_cookie_key'), TRUE);

            $validate_using = 'cookie';
        } else {
            // store session informations in variables
            $encryptedUserIDs = session()->get(getConfig('auth_session_id'));
            $enckey = session()->get(getConfig('auth_session_key'));

            $validate_using = 'session';
        }
Reply


Messages In This Thread
RE: Cookie not working in codeigniter 4. Need helper - by Chivinsdev - 04-20-2020, 01:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB