Jump to content

Cookies and 'Scope'


mhoctober

Recommended Posts

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....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.