27: Session and Cookies in PHP | PHP Tutorial | Learn PHP Programming | PHP for Beginners

Session and Cookies in PHP | PHP Tutorial | Learn PHP Programming | PHP for Beginners. Cookies and sessions are used when we want to collect or store data from users. An example could be if we want to make a login system or a shopping cart since these require user interaction. So if you are interested in having users on your website, then you need to learn this.


First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful 🙂

Material for this lesson: https://www.patreon.com/posts/php-27-download-15629638



  1. This guy is on point. I've been trying to learn this stuff for a while now. Great job on explaining the semantics.

  2. First of all, you have the best php tutorials on youtube! 😀

    Secondly, I was wondering if it's possible to share a session between two or more users. Here is what I mean.
    Let's say we have a $_SESSION['room'] (which stores a multidimensional array) is it possible to share a reference to this session between two users?

    I tried something like generating a random name for the room and store it inside a variable called $room_id and than I started a session $_SESSION[$room_id] but of course it didn't work :).

    Thanks in advance!

  3. I had my exam today and I got a question on session and cookies. I watched this video in the morning. Because of your video I could answer that question.

    Thank you 🙏💕

  4. setCookie(chocolate-chip, with-milk, warm). There seems to be laws that require a webmaster to ask if a visitor agrees to have their info stored as a cookie. How would you code the pop-up window or drop-down top floating window that asks the visitor for permission?

Comments are closed.