0

Can anyone tell me how to read cookie from subdomain. I can set the cookie for subdomain but unable to read it.

Please tell me what is the syntax in PHP to read cookie from subdomain.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Faisal Shaikh
  • 3,900
  • 5
  • 40
  • 77
  • 1
    See [stack overflow][1] [1]: http://stackoverflow.com/questions/9669428/how-to-read-main-cookie-from-the-sub-domain-with-an-existing-sub-domain-cookie-i Hope this helps you – matt Mar 21 '15 at 13:51
  • Try this [stack overflow][1] website i hope this helps you. [1]: http://stackoverflow.com/questions/3089199/can-subdomain-example-com-set-a-cookie-that-can-be-read-by-example-com – matt Mar 21 '15 at 14:03
  • Try this [stack overflow][1] website I hope this helps [1]: http://stackoverflow.com/questions/3089199/can-subdomain-example-com-set-a-cookie-that-can-be-read-by-example-com – matt Mar 21 '15 at 14:04

1 Answers1

1

If you're enabled to read in other subdomain, it's probably because you didn't properly set the cookie to begin with.

$date_of_expiry=time()+ 3600; setcookie( "cookie_name", "cookie_value", $date_of_expiry, "/", "example.com" );

It's important that you put the last argument for the cookie to be available in other subdomains.

Also, the cookies must be set before page output.

Ola
  • 68
  • 4
  • Yeah @Ola you are right but the cookie is not set by me. My client has set the cookie and I have to access it like that only. – Faisal Shaikh Mar 21 '15 at 13:20