How to Use Sessions and Cookies in PHP

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 55

  • @colonelvector
    @colonelvector 8 років тому +2

    Great tutorial, well explained.
    Been building a database and need to add in a login system for different levels of access. This gave me some great ideas

    • @john.morris
      @john.morris  8 років тому +1

      +colonelvector awesome! Glad to hear that.

  • @srkdonpro
    @srkdonpro 9 років тому +3

    Thank you very much for your simple but efficient explanation.

  • @anoop25601646
    @anoop25601646 10 років тому +1

    This video helped a lot. I am new to php and web development and was very confused among sessions and cookies. Thanks a lot.
    Would like to know, how php manages between two different sessions, in demo you have not assigned any unique id to the session, it's just start_session();

  • @screwtapeish
    @screwtapeish 8 років тому

    you have the best videos on youtube

  • @myiq170
    @myiq170 9 років тому

    That was just great, thank you loved it,
    Question so I want to play a video on my site and as the person goes through the site i want to remember where they left off on the video, even if they leave, so naturally after watching your tut, i see i would use a cookie not a session, but how would i capture where they were on the video with regard to time elapsed, and how do i load the video to that spot when they return ?
    I know thats sounds like a mouth full but if it makes sense I am sure you can give some insight ?
    thank you very much.

  • @theLegendOfYer
    @theLegendOfYer 10 років тому +4

    Sorry, just a little confused here based off of the video compared to how my professor explained it in class. The example you gave with the shopping cart, wouldn't that be less important/permanent data and therefor be more viable as storage in a cookie as opposed to the login/logout mechanism where the session indefinitely stores users login information until logout?

    • @vangoda
      @vangoda 6 років тому +1

      My understanding is that he did recommend cookies for that scenario, didn't he?

  • @Sanjeev.Network
    @Sanjeev.Network 6 років тому

    Best place to learn, thanking you bro.

  • @DefconUnicorn
    @DefconUnicorn 10 років тому

    The clients browser never sees the $_SESSION data unless your output it before the page is rendered. The only info the browser has is the session id which is needed to match the client to session. The client can not request any data from the session on its own. If you want to transfer secure info from say a login or a webform then use HTTPS. The client can alter $_GET and $_POST

  • @calvinschools
    @calvinschools 11 років тому

    Excellent tutorial. Nice explanation.

  • @lasskiss19
    @lasskiss19 11 років тому +1

    best tutorial video ever ..

    • @john.morris
      @john.morris  11 років тому

      lasskiss kshettri thanks! :)

  • @hvstlegod
    @hvstlegod 8 років тому

    nice tutorial i learned so much new from it! subscribed and liked

  • @patelmitul867
    @patelmitul867 9 років тому +5

    nice tutorials

  • @SinghatehAlagie
    @SinghatehAlagie 6 років тому

    Alagie Singhateh
    1 second ago
    hello sir, I come across your video while I was trying to fix my cookie problem. when I inserted my cookies into the database and if I want to see them all in my cookie model I show your cart is empty while inside my database is having some products already inserted into them. could you please help me to fix that please or I can even send you the code to check it for me if necessary? thank you so much waiting to hear from you soon as possible.

  • @xmx2012
    @xmx2012 8 років тому

    Thank you, helpful tutorial!

  • @sushantiwari6898
    @sushantiwari6898 9 років тому +1

    Thank you great help .

  • @sandy1995
    @sandy1995 8 років тому

    Can I use cookies instead of sessions in the first example?

  • @avinabochakraborty4241
    @avinabochakraborty4241 8 років тому

    its a great help sir. thank u

  • @ayuktia6397
    @ayuktia6397 7 років тому

    What should I use sessions or cookies if someone buys products, then stock of products will decrease, but they did not confirm / pay for it, so that their purchases will be canceled and stock products will increase again.

  • @zachgalvin1294
    @zachgalvin1294 8 років тому +3

    Why don't you advise using sessions for login purposes?

    • @109278123
      @109278123 7 років тому

      I have the same question. Why sessions are not good for login purposes and what would be the proper way to make a login using php?

    • @niftydos2111
      @niftydos2111 7 років тому +3

      Sessions are better for a login system. It's more safe than cookies.

    • @melpomenemm1363
      @melpomenemm1363 6 років тому +1

      Sessions are actually better for login

    • @mehmetselcukturer4429
      @mehmetselcukturer4429 6 років тому

      If one closes the browser then sessions are gone. You can not re log in with sessions then.

  • @RadosavLeovac
    @RadosavLeovac 9 років тому

    Hi, i have a problem on my website after user loges in or loges out session have some kind of delay and user stays loged out or loged in for next 10 15 seconds.

  • @HZArnel87
    @HZArnel87 8 років тому

    Then, is it smart to use cookies each time you need to and forget about sessions?

  • @Amjadcg
    @Amjadcg 7 років тому

    Thanks a lot :)

  • @zainamjed1
    @zainamjed1 9 років тому

    hey i am making a project management system i want userid is stored in user and i also want to use it in proposal as a foreign key can you guide me how can i do that

  • @goollata7557
    @goollata7557 10 років тому

    helpful

  • @iTrilby
    @iTrilby 10 років тому

    What happens to the session data if you're redirected away from site A to another site - site B (e.g. paypal to take a payment) and then site B sends you back to site A? Will the session data from site A stored before the redirect still be there when you return from site B?

    • @john.morris
      @john.morris  10 років тому

      The server won't know they left the page because that happens client-side. So, the session will remain. I think default length for sessions is 20 minutes... but will depend on server configuration.

    • @iTrilby
      @iTrilby 10 років тому

      John Morris Wicked, thanks so much for the quick reply. Great tutorial too, really helped

    • @john.morris
      @john.morris  10 років тому

      JanitorJo no problem and thanks! :)

  • @ameursemeh
    @ameursemeh 10 років тому

    hi I wanna get the user_id from the databases how can i do it please.

    • @myiq170
      @myiq170 9 років тому

      ameur semeh you need to be more specific with your question ?

    • @ameursemeh
      @ameursemeh 9 років тому

      I found it.
      and i ment how to filtre the database using user_id ... thank's :)

  • @jayantakumarroy543
    @jayantakumarroy543 7 років тому

    ATTENTION PLEASE
    when you changed between pages...the number incremented by 2 and not by 1..why sir??

    • @john.morris
      @john.morris  7 років тому

      That was so long ago. What time in the video did this happen?

    • @jayantakumarroy543
      @jayantakumarroy543 7 років тому

      The John Morris Show 7:58..when you changed between pages

    • @john.morris
      @john.morris  7 років тому

      Honestly, no idea. My guess is there's an edit I made in there and the page got refreshed "off-camera" for some reason. Maybe, my cat attacked my microphone or something. I don't think it has anything to do with the script itself.

  • @pianoLee-sx9dx
    @pianoLee-sx9dx 6 років тому

    Hey guys! Can someone assist me with my code? I am trying to create a remember function but the hash is not storing into my database..

  • @mikelangeloff8567
    @mikelangeloff8567 11 років тому

    Good, but you should have a more continuous speech. It's a bit mind-slowing

  • @ahmadaziz1800
    @ahmadaziz1800 7 років тому

    next time please show full screen

  • @amiruladli8057
    @amiruladli8057 8 років тому

    nice tutorial, i hope u can make it shorter ..

  • @neocyndaquil
    @neocyndaquil 7 років тому

    Very boring. I think to make it better, you should put the code on one side of the page, and then the browser on the other side. So, you can see the changes made faster. Most of the time, I just stare at your blank browser with a few text.

    • @john.morris
      @john.morris  7 років тому

      +neocyndaquil literally how every video I do now is