|
Posted by Ray Paseur on 11/25/05 20:41
You must set cookies before you send any output to the browser, but that is
not the same as saying before you code any statements. Similarly,
"session_start()" must come before any browser output.
You might be best served this way:
<?php session_start();
~~ execute some code, etc ~~
$_SESSION['v1'] = data_element_1;
~~ execute some more code, etc ~~
?>
The $_SESSION array should be available to all PHP pages of your site, so
long as the site visitor has followed the links from one page to the next.
I personally find sessions less confusing than cookies. ~Ray
"Michael Landin Hostbaek" <carlos@pez.dk> wrote in message
news:slrndodosr.316u.carlos@localhost.my.domain...
> cricketunes@yahoo.com tried to tell us something, and all I got was:
>> I thought I can store them up in different cookies and use them[Ideas
>> for a better method would be most welcome].
>
> Sessions ? Store the data in a DB ?
>
>> Should setcookie() be called before you code any other statements? When
>> I set 2 cookies at the top of the file and a third cookie after some
>> processing, the 3rd cookie doesnt seem to be set at all.
>
> Put the different variables in the same cookie - fx seperated by ':' or
> extract them later with split or explode.
>
>
> /mich
>
>
>
> --
> Michael L. Hostbaek
> FreeBSD mich 7.0-CURRENT FreeBSD 7.0-CURRENT
> Thu Sep 8 20:08 CEST 2005 root@mich:/usr/obj/usr/src/sys/S7010-1 i386
Navigation:
[Reply to this message]
|