Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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']); ?> ');

should this be working?
The alert box doesn't appear at all

Any help would be appreciated.

shagy :-)

Re: cookies

Quoted text here. Click to load it

 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 :: :: :: disk and FTP usage analysis tool

Re: cookies

The PHP is executed before the page is sent to the client. The
Javascript is executed when the page is received by the client.

Site Timeline