5 Replies - 214 Views - Last Post: 29 April 2019 - 09:34 AM Rate Topic: -----

#1 total212   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 19

Practical ways of using $_SESSION and $_COOKIE in procedural

Posted 27 April 2019 - 06:58 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.

Is This A Good Question/Topic? 0
  • +

Replies To: Practical ways of using $_SESSION and $_COOKIE in procedural

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14995
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: Practical ways of using $_SESSION and $_COOKIE in procedural

Posted 27 April 2019 - 08:31 AM

First up - 1988 or 1998? You have both dropped in your post.

Second - why would you need to practice it?
Was This Post Helpful? 0
  • +
  • -

#3 total212   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 19

Re: Practical ways of using $_SESSION and $_COOKIE in procedural

Posted 27 April 2019 - 09:51 AM

'98 is good :) This is where I am at educationally right now; I am intuitionally thinking that I need to master $_SESSION, $_COOKIE and a MySQL database (like I was doing the data types, so things like that, not whole MySQL). Basicaly things needed for basic writing like $_POST, $_GET, $_SESSION, $_COOKIE, mysqli, arrays, loops, conditionals. And the thinking is practice the most common things (again, we are in "1998", the "old school way") that are $_COOKIE and $_SESSION based:

1) login system (session and cookie)
2) forms that work on more than one php page (session)
3) temp info about the "contents of a shopping cart" (session)

Basically the most common uses of these in like cms / blog / forum / tube / online store. Or maybe somebody would have some info where I could learn on this - "use cases of cookies", and maybe the session part too.

Basically, it just seems like something that I need to improve now, "uncover".

I will be doing the OOP and Symfony later on. OOP is already done, but have not clicked into this yet (this mental pic of this). I was burned out by OOP like 3 times so far, so good edu, but I have not clicked into this yet.

So kind of get the procedural done and click into OOP. Finishing up the "beginner" level with the best online courses (like Udemy) and I will move on to "intermediate" as the next step.

But yes $_SESSION and $_COOKIE - what to practice with these two... getBootstrap.com, phpMyAdmin / mySQL and create something good / advanced with $_SESSION and $_COOKIE (the procedural way).
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14995
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: Practical ways of using $_SESSION and $_COOKIE in procedural

Posted 27 April 2019 - 10:03 AM

*shrug* Okay.. so you are not aiming to learn php3, but just those topics?

I would probably drop the whole "1998" bit as that will throw folks off thinking you want to learn php3. ;) :^:
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14995
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: Practical ways of using $_SESSION and $_COOKIE in procedural

Posted 27 April 2019 - 10:13 AM

As it is, plenty of folk have tread those topics. Great sites pulled up when searching "php when to use session" or "php when to use cookies".

Not to mention the tutorials found at the top of the site. Wohoo!
Was This Post Helpful? 1
  • +
  • -

#6 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2290
  • View blog
  • Posts: 6,981
  • Joined: 15-January 14

Re: Practical ways of using $_SESSION and $_COOKIE in procedural

Posted 29 April 2019 - 09:34 AM

There's not a lot to "master" when it comes to sessions and cookies. Just think of both of them as temporary data stores. All data stores do the same thing - they store data. A set of files, or a database, or cookies, or a session, are all data stores, just with different qualities like permanence and availability. Using a session is not really fundamentally different than using another data store, PHP just makes it easy to link the session up with a specific user (using cookies) so that you don't have to do that yourself. In practice, it's just another place to store your data. Since it is temporary, that means that in practice it is also only used to store data that you don't need to permanently save, just have available while the user is using your site. That means things like identifying who the user is, where you can look up the rest of their information that you do need to save in your database, which is a data store with much more permanence than sessions or cookies. Cookies would be somewhere between sessions and the database, you might save things in cookies that you want to be around for longer, but that you don't care if it gets deleted.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1