user863317
user863317

Reputation:

fetch values from cross browsers cookie

Can we Fetch Values from Cross Browser Cookie ??? For Example USer Can use mozilla or chrome or any other browser

when we print_r($_COOKIE);

All Browsers Cookie Will Print.

Upvotes: 0

Views: 770

Answers (5)

anon
anon

Reputation:

The only cookies your website can read are those that were issued from the same domain to the users current browser.

For security reasons, browsers will only send cookie information to the same domain which issued it. Sometimes, it's even limited to a particular subdomain, rather than being valid for the entire site. This is a very good thing, since cookie information often contains session data which can (partially or wholly) give access to a website account to the holder of a cookie. This is called session hijacking. Basically, if a browser served up all your cookies to every site which requested them, a malicious site owner could take over your accounts on other sites just by making a request to them using the cookie data for that site.

Also, cookies are local to the particular browser that a user is using at the time the cookie is created. This is why if you were to log into your Facebook account from Firefox, you would have to log in again if you switched to Chrome.

In short, what you are asking for is impossible, and it is impossible for very good reasons.

Upvotes: 0

Quentin
Quentin

Reputation: 944555

It isn't clear what you are asking, so here are three answers:

How can I use cookies and have them work no matter what browser my visitors use?

Cookies are a standard. You use the same HTTP headers (or JavaScript) to set them for all browsers, and all browsers send them to the server in the same way.

How can I access the cookies I set before the user switched browser?

You can't read a cookie stored by (for example) Internet Explorer when the user visits using (also for example) Chrome. Chrome does not have access to the cookies stored by Internet Explorer so cannot send them to the server.

How can I access cookies set by a different website?

You cannot read a cookie stored for a different domain as browsers will only send cookies belonging to a given website to that website (to do otherwise would require vast amounts of bandwidth and be a terrible security problem).

Upvotes: 0

nfechner
nfechner

Reputation: 17545

You will never be able to see all cookies set in a browser. Only the ones that are destined for the domain the request was sent to. For more information on cookies and the domain policy see here.

Upvotes: 1

cwallenpoole
cwallenpoole

Reputation: 82088

All browsers which have cookies enabled will send data to PHP which is added to $_COOKIE, assuming cookie data has been set...

That said, a browser will only "serve up" cookie data from itself and from the current domain. It cannot read another browser's cookies and it will not let you get data from another website.

Upvotes: 0

secretformula
secretformula

Reputation: 6432

No, cookies are stored only within one browser's cache. If you want to save data specific to a certain computer you will need to use Flash objects or server side databases

Upvotes: 2

Related Questions