Jump to content


Photo

Cookies and 'Scope'


  • Please log in to reply
No replies to this topic

#1 mhoctober

mhoctober
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 07 May 2006 - 07:52 PM

Searched the archives guys but cant find anything on the following...

this code snippet ...
<?php
session_start();
setcookie("cookieTransNum", $_POST['frmTransNum']);
echo 'Passed Form Value :'.$_POST['frmTransNum'];
echo '<br>';
echo 'cookieTransNum :'.$_COOKIE["cookieTransNum"];


Produces this output ....

Passed Form Value :10312
cookieTransNum :


ie. it would appear that the cookie has not been initialised with the value passed from the form.

However later in the code, and without repeating anything that would place a value into the cookie, I refer to the same cookie and it appears to be populated with the value passed from the form?

Is my expectation that the cookie will be initialsed with the form value in the first code snippet incorrect?

Do cookies have 'scope' ?

Many thanks....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users