473,396 Members | 1,864 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,396 software developers and data experts.

Cookie difference IE/FF

Hello all,
I'm trying to do something very simple: delete (or empty) a cookie.
The following code (which I found in the PHP doc) works fine in IE6 but not
in Firefox:
setcookie ("Cart", "", time() - 3600);
Any hint on what's wrong ? Yes, I issue this command before sending in any
HTML.
Thanks
--
Guillaume Dargaud
http://www.gdargaud.net/Antarctica/
Oct 6 '07 #1
5 1676
If you are trying to build a shopping cart i would highly reccommend
that you look into using sessions instead of a normal cookie.

see http://us3.php.net/manual/en/ref.session.php
Regards,

Paul

Oct 7 '07 #2
If you are trying to build a shopping cart i would highly reccommend
that you look into using sessions instead of a normal cookie.
Hmmm, yup. Given away by my variable name !
I want to do something extremely simple, so I thought it would be a good way
to do it. What's wrong with this approach ?
see http://us3.php.net/manual/en/ref.session.php
OK, thanks, I'll look it up.
--
Guillaume Dargaud
http://www.gdargaud.net/
"If brute force doesn't solve your problems, then you aren't using
enough."
Oct 7 '07 #3
>Hmmm, yup. Given away by my variable name !
I want to do something extremely simple, so I thought it would be a good way
to do it. What's wrong with this approach ?

Not everyone has cookies enabled in their browser. Cookies are
problematic in this way and should only really be used for non-vital
data.

Sessions on the other hand are far more reliable.

Oct 7 '07 #4
On Oct 7, 1:02 pm, macca <ptmcna...@googlemail.comwrote:
Hmmm, yup. Given away by my variable name !
I want to do something extremely simple, so I thought it would be a good way
to do it. What's wrong with this approach ?

Not everyone has cookies enabled in their browser. Cookies are
problematic in this way and should only really be used for non-vital
data.

Sessions on the other hand are far more reliable.
Indeed, cookies are a problem on some browsers, however, using
alternative session/cookies it's better, just like google does, or
digg, or whatever.

If set_cookie fails, you can try using the header() PHP builtin
function, just by trying something like:

<?php

header('Set-Cookie: cookie_name=cookie_value; expires=Tue, 06-Oct-2009
16:36:23 GMT; path=/; domain=.yourdomain.com');

?>

This is slower than the regular PHP cookie version, however, at this
step, you get more feedback about what happens there.

See this example below, to learn how google does the cookie setting
part, and it seems to work just great:

http://www.xheaders.com/index.php?ur....google.com%2F

(watch what happens inside the SET-COOKIE area)

In my opinion, cookies are good, however unsafe without any pre-
escaping/pre-processing activity.

On the other hand, sessions, are slower since disk access times are
slower than a cookie "PHP based" checkup based on your visitor's
browser feedback. This can be solved by storing sessions data inside
MYSQL, so everything is doable in one way or another.

So, when creating a web app, I prefer to use both cookies and
sessions, depending on what works for each user.

Try using JS to check existance of cookies, or anything else, there
are plenty of workarounds if you want to use them, however, try to
play safe and defensively when coding, you never know.

Best luck!

Vladimir Ghetau
http://www.Vladimirated.com

Oct 7 '07 #5
I found what the problem was: I had forgotten the path info '/' in one of
the setcookie calls and it was creating a great deal of confusion.

As to using sessions, I only need something very simple, and it doesn't need
to be secure (famous last words !) as security is handled by another system.
A javascript workaround handles the cookieless fine. As for the
scriptless... I even have a workaround for that.

But I'll keep it in mind. Thanks for the previous answers.
--
Guillaume Dargaud
http://www.gdargaud.net/Humor/LastWords.html
'Come out and say that, Tyson !'
Oct 8 '07 #6

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

Similar topics

7
by: Henry Hartley | last post by:
I've got a PHP system working on a development server (Windows 2000/IIS5/PHP 4.3.3) but it doesn't seem to be working quite right on the testing server (same except PHP 4.2.3). I upgraded the PHP...
6
by: Ajay | last post by:
hi! i am printing a simple cookie, but instead of printing um=name:blah&access:admin&exp:2312390.909 its printing um="name:blah&access:admin&exp:2312390.909" why the quotes?
8
by: Matt | last post by:
I want to know if user disable cookie, will the session still working? Actually I remember we could disable cookie in IE before (not sure what version, but I couldn't see the option anymore. Now I...
1
by: JJ_377 | last post by:
What is the reason for the difference between the way Netscape 7.1 (NS) makes a cookie and Internet Explorer 6 (IE) makes one in the following case: The following JavaScript cookie assignment...
15
by: Oleg Leikin | last post by:
Hi, (newbie question) I've created some simple .NET ASP application that should store cookies at the client machine. According to the documentation cookie expiration time is set via...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
2
by: ad | last post by:
What is different between Request.Cookie and Response.Cookie? Are they independent?
15
by: Edwin Knoppert | last post by:
I have searched but info is limitted. In my test app i used a non persistant cookie for forms authentication. slidingExpiration is set to true On run and close and rerun the login remains ok....
2
by: rn5a | last post by:
A web.config file has the following code: <configuration> <system.web> <authentication mode="Forms"> <forms name="NETConnectCookie" loginUrl="Login.aspx"> <credentials passwordFormat="SHA1"/>...
8
by: LayneMitch via WebmasterKB.com | last post by:
I'm supposed to develop a page that asks info as form values and when you hit "submit" it takes you to a page that reads the values you entered into the first page and displays those values in a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.