Practical ways of using $_SESSION and $_COOKIE in procedural PHP

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
total212
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Apr 27, 2019 5:56 am

Sat Apr 27, 2019 5:57 am

I am researching the topic of most common practical applications / uses of $_SESSION and $_COOKIES in the old school procedural PHP (like there is no OOP yet, no Symfony / Laraval, "1998"). It would be better to post two separate threads for it, but I am posting just one (these superglobals work together too). I basically need to bite into these two better and practice the practical uses of these two. Like:

1) Login system (session and cookie)
2) Form that spans on several pages (session)
3) Storing something in a cookie when a user comes back (lets say), but I guess we would rather store it in a database and pull it from there (like a "remarketing info", this is the name of what somebody has suggested in some other place).

Basically, year 1988 and "10" most common uses of $_SESSION and $_COOKIE (or these two together), so that I could practice it. I know how they work but I would need to know what to built from it, for learning the procedural PHP.

Thanks.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 831
Joined: Mon Feb 22, 2016 5:52 pm

Sat Apr 27, 2019 11:13 am

The internet is littered with 1990s scripts, insecurely and badly misusing sessions and cookies.

Is this post actually genuine or do you have another agenda?

total212
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Apr 27, 2019 5:56 am

Sun Apr 28, 2019 12:04 am

Yes, it is genuine as I am working on:
a) procedural
b) oop
c) Matt Zandstra - "Objects, patterns and practice" (I think that it is correct to read it prior to learning Symfony 4)
d) Symfony 4

I do it with 9 the best paid courses from the Net (I mean something like Udemy at the best discounts, nothing expensive like Plularsight, lets say), 2 Murach's books (Mysql plus Mysql and PHP), youTube and some other sources, whatever is there.

So need to fill myself up with these usages of $_COOKIE and $_SESSION in an old school procedural way, but in a "modern way" (it can be, like PHP7 and not PHP3; I mean I know that this is not the best now, there is Oauth2 or something else for login as the best thing so what I do is not what I will be using, but this is ok, I need to learn this first) and then I need to click into OOP (get that mental pic) and based on what I already learned, which is quite a lot.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 831
Joined: Mon Feb 22, 2016 5:52 pm

Sun Apr 28, 2019 4:30 am

Seems odd, but ok :D

As indicated, the internet does have some very old scripts still promoted today which would fit the bill including some which claim to be oop (that aren't, simply throwing the odd object and using new at scripts doesn't make them ooop), the problem of course is trying to work out which is from when since many of these things aren't dated or are dated more recently but still go back then. Another problem is that a lot of sites used $_GET to transfer information from page to page rather than sessions and cookies and a mixture of storing the information themselves (still done today).

An answer may be to get your hands on books from that era (bible series for instance).

An alternative would be to work backwards by learning current methods, and then you could play find the old script / method.

PHP 4
MySQL

I'm not sure that I have helped much, but, Good luck with your project 8)

Post Reply