Re: Cookies & sessions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/1/20  <clancy_1@xxxxxxxxxxxx>:
> When you are working with sessions, provided you start your program with session_id(), you
> can then do anything you like with session variables at any point in your program.

Hi,

You meant session_start() instead of session_id(), right? But yes,
once you started a session (before any output is sent to the browser,
that includes echo and print statements, empty space chars, etc) you
can do anything you like with the $_SESSION array, being able to read
the stored values in other requests / scripts of your app, as long as
the session is started.

> In my
> original question I asked if there was a cookie equivalent.

As far as I know, yes, there is. You set a cookie using the
setcookie() function. This function, in the same way as
session_start(), must be called before any output is sent to the
browser. Once a cookie is set in the client, you can read the $_COOKIE
array in any subsequent request of your client, in any point of your
app, just like session.

>
> Someone said there was, but the above is simply demonstrating that their suggested
> solution doesn't work. It appears there is no solution, but that the workaround is to turn
> on output buffering, at least until you finish setting cookies, so that you can be certain
> that no output is generated before this point.

You don't need to use output buffering at all. You only need this
mechanism if your script needs to output stuff before the
session_start() or setcookie() functions get executed.

Well, I hope this information is helpful.

Cheers,
Bruno.

>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux