Welcome Guest, Not a member yet? Register   Sign In
set_cookie not setting cookie
#14

[eluser]shallway[/eluser]
To me the CI set_cookie function works fine.

Did you pass the correct unix time stamp as the to the $expire parameter?

Here is from php.net
Quote:The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

if you simply do this set_cookie( 'name', 'value', 86500, '', '' ) the cookie will not be set, because 86500 is NOT a valid unix time stamp. A valid unix time stamp should always be a 10 digits number. In other words if you do this :
Quote:set_cookie( 'name', 'value', time()+86500, '', '' );
it should work.

The problem is the PHP setcookie function seems not validating the number to be a 'valid' unix time stamp, it only checks if what's pass as the 'expire' parameter is a long number or not. That means you won't get any error message when you pass 86500 into it.

Hope this helps.


Messages In This Thread
set_cookie not setting cookie - by El Forum - 03-12-2008, 08:30 AM
set_cookie not setting cookie - by El Forum - 03-12-2008, 08:34 AM
set_cookie not setting cookie - by El Forum - 04-01-2008, 07:17 PM
set_cookie not setting cookie - by El Forum - 04-01-2008, 08:14 PM
set_cookie not setting cookie - by El Forum - 04-01-2008, 08:49 PM
set_cookie not setting cookie - by El Forum - 04-01-2008, 08:55 PM
set_cookie not setting cookie - by El Forum - 04-01-2008, 09:02 PM
set_cookie not setting cookie - by El Forum - 04-01-2008, 09:04 PM
set_cookie not setting cookie - by El Forum - 06-26-2008, 05:38 PM
set_cookie not setting cookie - by El Forum - 06-26-2008, 05:59 PM
set_cookie not setting cookie - by El Forum - 06-26-2008, 07:12 PM
set_cookie not setting cookie - by El Forum - 06-26-2008, 09:29 PM
set_cookie not setting cookie - by El Forum - 06-26-2008, 09:40 PM
set_cookie not setting cookie - by El Forum - 02-02-2009, 02:14 AM
set_cookie not setting cookie - by El Forum - 02-02-2009, 02:20 AM
set_cookie not setting cookie - by El Forum - 02-02-2009, 02:51 AM
set_cookie not setting cookie - by El Forum - 02-04-2009, 06:09 AM
set_cookie not setting cookie - by El Forum - 06-07-2009, 06:27 AM
set_cookie not setting cookie - by El Forum - 06-08-2009, 12:32 PM
set_cookie not setting cookie - by El Forum - 06-29-2009, 02:12 AM
set_cookie not setting cookie - by El Forum - 08-20-2009, 10:05 PM
set_cookie not setting cookie - by El Forum - 08-31-2010, 01:20 AM
set_cookie not setting cookie - by El Forum - 08-31-2010, 01:38 AM
set_cookie not setting cookie - by El Forum - 08-31-2010, 10:10 AM
set_cookie not setting cookie - by El Forum - 03-04-2011, 09:15 AM
set_cookie not setting cookie - by El Forum - 06-28-2012, 08:25 AM
set_cookie not setting cookie - by El Forum - 06-28-2012, 10:01 AM
set_cookie not setting cookie - by El Forum - 06-28-2012, 12:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB