You are here: Re: Cookie difference IE/FF « PHP Programming Language « IT news, forums, messages
Re: Cookie difference IE/FF

Posted by Vladimir Ghetau on 10/07/07 16:46

On Oct 7, 1:02 pm, macca <ptmcna...@googlemail.com> wrote:
> >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?url=http%3A%2F%2Fwww.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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация