You are here: Re: cookies « PHP Programming Language « IT news, forums, messages
Re: cookies

Posted by Andy Hassall on 10/06/47 11:34

On Wed, 14 Dec 2005 17:25:50 +0200, shagy <noemail@noemail.com> wrote:

>is it possible to set a with javascript then read that cookie with
>$_COOKIE all within <script language='JavaScript'> tags for example:
>
><script language="JavaScript">
>function test(param) {
> var expiration = new Date();
> expiration.setSeconds(expiration.getSeconds + 30);
> document.cookie = "kae=" + param + ";" + "expires=" +
>expiration.toGMTString() + ";path=/;";
>
> alert(' <?php echo ($_COOKIE['kae']); ?> ');

No, you have the execution order the wrong way around. The PHP code is
executed on the server before it ever reaches the client. The Javascript code
is run on the client afterwards.

The cookie hasn't been set yet when the PHP code runs. You whould end up with
a blank Javascript messagebox (if any).
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

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

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