Welcome to WebmasterWorld Guest from 34.207.78.157

Forum Moderators: coopster & jatar k

Ways of using $ COOKIE in procedural PHP

     
1:33 pm on Apr 27, 2019 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 23, 2014
posts:44
votes: 0


I am still learning PHP and I could use info on what are the most common usages / applications of $_COOKIE in the most common types of scripts like cms / blog / tube / forum / online store. I know how cookies work, but these actual applications (maybe like 10 or more) would be what I would actually need and then use the info for practicing it.

I basically need to ďuncoverĒ $_SESSION and $_COOKIE more, these actual usages of it, applications, in procedural PHP.

Thanks.
5:58 pm on Apr 27, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15636
votes: 795


Are you looking for cut-and-paste answers? That's the wrong approach; you need to look at it conceptually. In the case of $_COOKIE, the concept is: the exact details of page rendering will depend on the content of one or more cookies, which convey information about what the user has previously done on your site.

Simple real-life example (Iíve since dropped this, but it did what it was intended to do):
Consider a linked sequence of pages A B C D, intended to be viewed in order. A is the entry page; B links back to A and then forward to C; C links back to B and A and forward to D; D links back to all the others. The navigation menu will show the available pages.

But then: If user has previously seen page C, then page A will also link to C; if user has previously seen page D, then pages A and B will link to everything. Itís done by reading the value of a cookie (or simply checking for its existence) and then showing or not showing the specified menu item.

Make sure the site remains functional for users who, for any reason, do not retain cookies.
5:52 am on Apr 28, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:9714
votes: 925


Make sure the site remains functional for users who, for any reason, do not retain cookies.


Or allow them in the first place.

Keep in mind that cookies are also coming under other potential regulations, such as GDPR ...
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members