Jump to content


Photo

session cookie


  • Please log in to reply
3 replies to this topic

#1 werty37

werty37
  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts

Posted 30 May 2006 - 06:17 PM

Hi

<?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();
?>

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


#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 30 May 2006 - 06:25 PM

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)?
~ D Kuang

#3 werty37

werty37
  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts

Posted 30 May 2006 - 06:47 PM

So i really dont have to check that the cookie is from my site or not unlike normal cookies.


#4 werty37

werty37
  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts

Posted 30 May 2006 - 07:20 PM

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?

<?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();
?>

Thanks in advance
werty37




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users