473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

URGENT: cookies not working anymore!

hello, any idea why the following code does not work?!!

<?

$cookieExpire = 864000000;

setcookie("a", "love", $cookieExpire);
header("Set-Cookie: lc=50; expires=$cookieExpire");
header("Set-Cookie: id=test; expires=$cookieExpire");

while (list ($key, $val) = each ($_COOKIE)) {
echo "$key => $val<br />\n";
}

?>

Only the last cookie, "id=test" is set. Why?

Also, how should I delete all cookies set from my website in one command?

Thanks!!

Jul 16 '05 #1
1 5544
Why are you setting one cookie with setcookie() but setting the others
with header()? For testing reasons I presume. Get rid of the other
header() lines and just use setcookie().

Try setting $cookieExpire to time() + number of seconds (or decrease
$cookieExpire a bit - 86400 is 1 day so 864000000 is about 27 years...)

To delete a cookie, set it again (use setcookie()) with the value
parameter set to "" and everything else the same.

Use a browser such as Mozilla and set it to ask permission before a
cookie is set - you can see all the details of the cookie there, such as
the date it is due to expire. This makes it much easier to debug cookie
problems.

Hope this helps.

MK.

Craig Matthews wrote:
hello, any idea why the following code does not work?!!

<?

$cookieExpire = 864000000;

setcookie("a", "love", $cookieExpire);
header("Set-Cookie: lc=50; expires=$cookieExpire");
header("Set-Cookie: id=test; expires=$cookieExpire");

while (list ($key, $val) = each ($_COOKIE)) {
echo "$key => $val<br />\n";
}

?>

Only the last cookie, "id=test" is set. Why?

Also, how should I delete all cookies set from my website in one command?

Thanks!!


--
MeerKat

Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Spidah | last post by:
I am working on a shopping cart for a client and have struck a weird problem. The client's ssl setup is on a different url to the main site. As a result we get two copies of our shopping cart...
1
by: Tony Archer | last post by:
(Forgive the dupicate post, I had left out the OS Version out of the prior post.) Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a...
6
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a...
0
by: Amratash | last post by:
Hi, I needyour help.Its urgent. My main aim is to log the site activities in a database at runtime. I'm using W3C Extended Log File format for logging information. I can use ODBC Logging directly...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
6
by: André | last post by:
Hi, Not sure it's a asp.net problem, but i discovered it with asp.net, so ... I need to pass data from page to another, so i use cookies for that. My problem is that when a certain amount of...
1
by: maheshv | last post by:
Hi all, Dear friends, i am facing a problem when using cookies i need help of yours... Lets come to the issue, i am using cookies all over the site, it is working all fine, the only problem is...
0
by: Chandu | last post by:
Urgent Openings for SE/SSE/TL in .Net for Bangalor Dear , Greetings from Job Cookies India Pvt Ltd., We have Urgent Openings for SE/SSE/TL in .Net for Bangalore Skills Required: 4+Yeard...
7
by: cmrchs | last post by:
Hi, In Windows Vista: where does asp.net write its cookies? I use HttpCookie objCookie = new HttpCookie("nameCookie"); in Win2000 (and later) they used to be in C:\Documents and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.