Welcome Guest, Not a member yet? Register   Sign In
Problem with Cookies not saving
#1

[eluser]R_Nelson[/eluser]
heres the code im using to set the cookie
Code:
$cookie = array(
            'name'   => 'Projects',
            'value'  => '325',
            'expire' => '2410000'
        );
        $this->input->set_cookie($cookie);

if i do a phpinfo() i can see the value of 325

i have IE 8 set to except all cookies but im not seeing the cookie but other websites come thru just fine!
#2

[eluser]InsiteFX[/eluser]
in application/config/config.php change the session cookie name to cisessions IE does not like the underscore

expire has to be an int not a string!
Code:
'expire' => 2410000

// example
'expire' => time() + 900

InsiteFX
#3

[eluser]R_Nelson[/eluser]
i have tried what you suggested and im still not getting a cookie also im not getting it in firefox or chrome!
#4

[eluser]R_Nelson[/eluser]
ok i got it to work in Firefox and chrome i may have to do some looking around for IE8
#5

[eluser]InsiteFX[/eluser]
I just tested this on my Windows 7 Pro running IE9 switched to IE8 and IE7 modes doing a refresh and the cookie shows up in my developer tools!
Code:
$cookie = array(
    'name'   => 'Projects',
    'value'  => '325',
    'expire' => '2410000'
);

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

InsiteFX
#6

[eluser]R_Nelson[/eluser]
i got it to work my self but its deleting the cookie when i close the browser do i have something set wrong?
#7

[eluser]jgetner[/eluser]
why not just use regular php instead of CI? this would be faster and validating a cookie is as easy as going isset();

Code:
setcookie('projects' , '325' , time() + 3600);

function get_cookies($name)
{
    if (!isset($_COOKIE[$name]))
    {
        return(FALSE);
    }
    
    else
    {
        isset($_COOKIE[$name])
        {
            return htmlspecialchars($_COOKIE[$name]);
        }
    }
}
#8

[eluser]R_Nelson[/eluser]
Thanks i got it to work i forgot the single quotes around the time now it works just fine!

thx much for your time!

and Jgetner that was my next step if i couldn't get this to work so thx for trying to help Smile
and as far as why use CI because get_cookie('cookie_name'); is just so much easier for me Smile




Theme © iAndrew 2016 - Forum software by © MyBB