Jump to content

Archived

This topic is now archived and is closed to further replies.

werty37

session cookie

Recommended Posts

Hi

[code]
<?php ob_start('ob_gzhandler');

if (!isset($_COOKIE['PHPSESSID']))
{
session_start();
ob_flush();
if (!isset($_COOKIE['PHPSESSID'])) { echo "Cookies are disabled."; }
else { echo session_id(); }
}

ob_flush();
?>
[/code]

ok, i want to know how i can access my phpcookie, since all the people who use php with sessions
have a PHPSESSID.
lets say for example- your site uses php -session enabled, and my site uses the same, if a visitor
vists your site and my site at the same time, how can i access only my PHPSESSID cookie and not yours.

Hope i am making it clear...

Thanks in advance

Share this post


Link to post
Share on other sites
PHP will access only the cookie from your site, because it's sent from the client.

The client should send the correct cookie; otherwise it could be a major security risk, don't you think (you'd be able to steal ppl's cookies)?

Share this post


Link to post
Share on other sites
So i really dont have to check that the cookie is from my site or not unlike normal cookies.

Share this post


Link to post
Share on other sites
HI
So i have a problem with this code. it always prints "Cookies are disabled."
on first request even though i flush the buffer to the client.
Secondly, when i check the cookie details in the browser,
i can see that session_set_cookie_params() did not work.
What is wrong?

[code]
<?php ob_start('ob_gzhandler'); session_start();

if (!isset($_COOKIE['PHPSESSID']))
{
session_set_cookie_params("3600","/test","localhost","0");
session_start();
ob_flush();
if (!isset($_COOKIE['PHPSESSID'])) { echo "Cookies are disabled."; }
}
else { echo session_id(); }
//ob_flush();
?>
[/code]

Thanks in advance
werty37

Share this post


Link to post
Share on other sites

×

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.