charanv Posted August 31, 2009 Share Posted August 31, 2009 Hi I am charan. I am trying to set cookie but for some reason the cookies cannot be retrieved after the browser is closed. I am setting the expiredate to be after 500 days.. I found that in my php.ini file there is a column which says session.cookie_lifetime = 0; Is this causing the error.. What should I do if Iwant to access cookies even after the browser is closed for 500 days period.. Could you also enlighten me with the difference between setcookie function's expiration date and session.cookie_lifetime = value ... My question when I am setting the cookie's expiration date in myscript to be valid for 500 days why cant I retrieve the cookies. Infact when I went opened the browser properties and then select view cookies I can see the cookie. This is how I am setting the cookie. /* $track = "12345"; setcookie("test", $track, time()+60*60*24*7); */ Thank you Charan Link to comment https://forums.phpfreaks.com/topic/172594-php-cookie-problem/ Share on other sites More sharing options...
Zyx Posted August 31, 2009 Share Posted August 31, 2009 Well, I'm not surprised that you can't set the cookie - your code is enclosed in comments . The php.ini setting is used, if you do not set any expire time in PHP. Moreover, everything depends also on many other factors, such as server domain and cookie path. How do you read the cookie? Link to comment https://forums.phpfreaks.com/topic/172594-php-cookie-problem/#findComment-909839 Share on other sites More sharing options...
charanv Posted August 31, 2009 Author Share Posted August 31, 2009 Hi Zyx The comment I used just to indicate the start and end of the code in forum I am actually using the code without the comments. To read the variables this is how I do it: echo $_COOKIE["test"]; Here is the problem I can read the cookie once I set as long as I don't close the browser once I close the browser I am unable to read the cookie. Thank you Charan Link to comment https://forums.phpfreaks.com/topic/172594-php-cookie-problem/#findComment-909851 Share on other sites More sharing options...
charanv Posted August 31, 2009 Author Share Posted August 31, 2009 Hi I figured out the problem.. I was using the same name for the var for both sessions and cookies that was messing things up... Sorry about the confusion .. Thankx all... Link to comment https://forums.phpfreaks.com/topic/172594-php-cookie-problem/#findComment-909903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.