Stupid setcookie() question...

From: Bonge Boo! (bingbong_at_spamcop.net)
Date: 02/21/05


Date: Mon, 21 Feb 2005 21:03:42 +0000

Sorry if this is blazingly obvious.

I have a number of multipage forms and I wish to be able to save "sessions
state" between.

I can happily set them up so that hidden fields get created with the values
of the form fields from the previous pages get created and hence sent to the
next form in the series.

However if some goes from Form4 back to Form1 then I don't want them to have
to fill in all the forms gain.

So cookies I thought.

Havoever Iseem to be having a problem

Lets say I place the following at the top of the page, before any HTML

setcookie('instruction_type', $_POST['instruction_type'], time()+1800);
print "We set the cookie to: " .$_COOKIE['instruction_type'];

All is good. Apart from this.

ITS PRINTING OUT THE VALUE OF THE COOKIE PRIOR TO THE FORM BEING SUBMITTED.

So if the cookie was value was previously "Bob" and I've changed the form
value so it is now "John" then John still gets printed out.

However if I reload the page then "John" gets printed correctly.

So can you only set a COOKIE vale on page, not view it on the same page as
it has been set on?



Relevant Pages

  • Re: Session Cookie not accessible across Sub-Domains
    ... I don't set the ASP.NET Session cookie. ... "John Timney (ASP.NET MVP)" wrote: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HttpWebRequest.GetResponse does not work on some uris
    ... > after returning the cookie? ... a network monitor like ProxyTrace from http://pocketsoap.com. ... I'd look at the interaction between IE and the remote site, ... John Saunders ...
    (microsoft.public.dotnet.framework)
  • Re: Hatred of Paul?
    ... >believe there is one song where John says "Cookie" or something like ... >that which, I believe, may be a vague imitation of cookie Monster. ... Extended, alternate, and out- takes of POB tracks that appear on ... bootlegs reveal John enjoying himself and the session. ...
    (rec.music.beatles)
  • Re: How do I Change Computer Name
    ... >>I have purchased a used computer with Windows XP home and ... >>visit a website and get a cookie it has a name in front ...
    (microsoft.public.windows.mediacenter)
  • Re: cookies vs. hidden fields
    ... >>Having said that, all other things being equal, I'd use hidden fields. ... >>Cookie support is optional, a cookie file can be deleted by a user, etc. ... without there being one major flaw that one has over the other ...
    (comp.lang.perl.misc)