/    Sign up×
Community /Pin to ProfileBookmark

PHP’s own cookie test

One thing that has been nagging me for a very long time is PHP’s session option to use alternative methods of transporting the session id from client to server.

Normally when I check for cookies, it is done via JavaScript and the most common Server Side way is using a redirect to set and then check for a cookie.

But since PHP has the option to use alternative transportation like GET and POST, it means that PHP needs a way of checking if cookies can be used on the client or not.

The Question:
How does PHP check if cookies is enabled?
Is it just a redirect set and check?

And by redirect I mean send a Set-Cookie header, reload and check if it is set.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@SrWebDeveloperFeb 26.2010 — Yep, set/redirect/check is how to test.

The advantage of using PHP is that it's a server side check, anyone can disable Javascript in their browser.

-jim
Copy linkTweet thisAlerts:
@dk_zero-coolauthorFeb 26.2010 — Ok Thx.

Well it would be nice if future browsers was given a standard request header containing the status of cookies.
Copy linkTweet thisAlerts:
@SrWebDeveloperFeb 26.2010 — Get to work on that, right away! :p
Copy linkTweet thisAlerts:
@dk_zero-coolauthorFeb 26.2010 — It would properly not matter.

Even if this was made, it will take 25 years before Internet Explorer support it :S
Copy linkTweet thisAlerts:
@SrWebDeveloperFeb 26.2010 — In Microsoft Vista service pack 1,398,340,820,938,904,802 in the year 2035 according to my magic 8 ball.
×

Success!

Help @dk_zero-cool spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...