Re: session & cookies
| From: | Teodor Cimpoesu | Date: | Wed, 27 Sep 2000 17:48:04 +0000 |
| Subject: | Re: session & cookies | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17765@lists.php.net to get a copy of this message | ||
Hi Radu!
On Wed, 27 Sep 2000, Radu Filip wrote:
>
> Hi! I have php compiles as module. And I have a site where all the php
> pages must use share the same global variables, using session. I want to
> transmit the session ID using cookies.
>
> I'd like some to show me a few lines of code that do following:
> - to check if it is set a cookie that contains PHPSESSID
> - if it not exist, to create a session and set a cookie with the session
> id
> - if it exists, to "connect" the page to session using the id from cookie
>
> I have tried seevral times to write such code but I failed.
>
shortest answers is from the manual:
<?
session_register('count');
$count++;
?>
a longer one would be:
<?
session_start();
if (!session_is_registered('count')) {
$count = 0;
session_register('count');
echo "Session registered the 'count' var\n<br>";
}
echo "Count is now = $count\n<br>";
++$count;
?>
The PHP manual (LVIII. Session handling functions) is a good start
if you ever want to code in PHP using sessions.
gl.
-- teodor