Flask Tutorial #5 - Sessions

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ต.ค. 2024

ความคิดเห็น • 186

  • @thomaswells4976
    @thomaswells4976 ปีที่แล้ว +32

    This guy doesn't waste any time with superfluous detail or pontificating on random design features. Just gives you exactly what you need to understanding the fundamentals. Quite a gifted teacher IMHO. Thanks for the help!

  • @YahyaMowiena
    @YahyaMowiena 4 ปีที่แล้ว +47

    Great explanation skills, Thanks. Yet, for that particular topic, these are client side sessions that are stored in a cookie, and not stored on the server side. They are encoded and not encrypted. The secret key is to cryptographically sign them.

    • @peschebichsu
      @peschebichsu 3 ปีที่แล้ว

      Thanks for your comment. But are they still safe / good practise to remember a logged in user, or should something else be used instead?

    • @shauntechstudios344
      @shauntechstudios344 2 ปีที่แล้ว

      why its coming too many redirects

  • @idk-qs8ft
    @idk-qs8ft 2 ปีที่แล้ว +13

    this tutorial is helping me more in my mid-term project than the classes themselves, thank you sooo much

  • @sindhukorubilli7502
    @sindhukorubilli7502 2 ปีที่แล้ว +3

    The amount of happiness I get when I was stuck, then finally came out of the issue is immacluate. Thanks for the help!

  • @gioxc88
    @gioxc88 3 ปีที่แล้ว +77

    Thanks for the tutorial. I just would like to clarify that the session object imported from flask is actually a client-side session, meaning that the data are stored in the client browser, not in the server as you said at the beginning of the video.

    • @itpugil
      @itpugil 3 ปีที่แล้ว

      Question, what should be imported to have it get saved on the server rather than the client?

    • @chachacha1289
      @chachacha1289 2 ปีที่แล้ว

      True, Flask's sessions are client-side sessions...

    • @zerodivided3676
      @zerodivided3676 2 ปีที่แล้ว +2

      Thanks for pointing that out. I also frowned a little when he said that, because he also said that all that session data is forgotten when the user quits browsing.
      Which is false (unless the browser is set to clear the cookies upon closing, which they aren't by default).

    • @teguhpambudi8477
      @teguhpambudi8477 2 ปีที่แล้ว

      nice clearout, apreciate

    • @forrestgoryl1650
      @forrestgoryl1650 2 ปีที่แล้ว +1

      @@itpugil Hi, your comment was 6 months ago so don't know if you still need the info or not, but you can use a database like sqlite3. Server side storage = databases

  • @ddfgrtsd
    @ddfgrtsd 4 ปีที่แล้ว +22

    Dude. All of your tutorials is top-class material. I'm extremely thankful for all of the things you've taught me. It's simple and precise! THANK YOU! :)

    • @eduardmart1237
      @eduardmart1237 7 หลายเดือนก่อน

      Is session just a cookie?

  • @4citi
    @4citi 2 หลายเดือนก่อน

    explaining the session and the purpose of secret key was more clear than any other I heard. Thanks

  • @ignskeletons
    @ignskeletons 2 ปีที่แล้ว +7

    I'm using your Flask course as a jumping point into learning Python and eventually cybersecurity and ethical hacking with python. I just wanted some foundations into building simple web apps, learning the Python lang, and this is helping me a ton get my foot in the door into what I want to eventually learn with more in-depth courses later. TY!

  • @dominiquedewet3311
    @dominiquedewet3311 3 ปีที่แล้ว +4

    This was so great. I've searched the internet for hours and you're the first person to actually help me.

  • @ermacheton
    @ermacheton 4 ปีที่แล้ว +6

    congratulations my young man, not only you are super smart, but extremely well articulated...

  • @kilianvounckx9904
    @kilianvounckx9904 4 ปีที่แล้ว +20

    When you use pop on a dictionary, the first argument is the key which you want to delete. When you use pop it will return the value associated with that key. If the first argument is not found as a key, it will return the second argument.
    You can then assign the returned value to a variable the same as with popping from a list.
    Most of the time you know the key exists though, so you just put None as the second argument.

    • @atharvakadlag1937
      @atharvakadlag1937 4 ปีที่แล้ว

      Thanks man

    • @kilianvounckx9904
      @kilianvounckx9904 4 ปีที่แล้ว

      @@capslock3250 yeah i meant dictionary.
      Edited it. Thanks

    • @Jkfgjfgjfkjg
      @Jkfgjfgjfkjg 4 หลายเดือนก่อน

      If you know the key exists then you don’t need the second argument. You provide the second argument just in case the key isn’t found, in which case the second argument is returned instead of an error being thrown.

  • @saishyam8583
    @saishyam8583 3 ปีที่แล้ว

    whatever coding tutorial i search for there are a bunch of tutorials in results and many of them has more views that techwithtim ones but eventhough i choose tim

  • @sahilbaig9860
    @sahilbaig9860 3 ปีที่แล้ว +5

    This was exactly what I was searching for......Thanks a lot

  • @mhfd9042
    @mhfd9042 2 ปีที่แล้ว

    Short, sweet, simple, straight to the point
    Love it !

  • @NDP1492
    @NDP1492 4 ปีที่แล้ว

    Just wanted you to know this was the only video/web page that properly described the use of sessions without either being voerly complex, or just plain wrong. Thanks!!

  • @phanngocvy1504
    @phanngocvy1504 4 ปีที่แล้ว +1

    Great tutorial, great and clear voice for easy to understand

  • @RameenFallschirmjager
    @RameenFallschirmjager 3 ปีที่แล้ว

    Tim you are very dear to me, I love you bro. Your family should be very proud of you. You've got a very great channel.

  • @knowingitintobeing6888
    @knowingitintobeing6888 ปีที่แล้ว

    Tim you are literally saving me, thank youuu so so so much for your help
    u are my favourite ❤️❤️

  • @MbuRasmeni
    @MbuRasmeni 4 ปีที่แล้ว

    Great tutorial!!! I wasn't even halfway through the video and already found the solution to my problem

  • @linda6892
    @linda6892 2 ปีที่แล้ว +1

    Your tutorials are excellent. Thanks

  • @juneciel
    @juneciel 4 ปีที่แล้ว

    One of the best tutorials for flask!!

  • @mayilvahanan2196
    @mayilvahanan2196 2 ปีที่แล้ว +1

    9:38 Thanks Bro That's Quite Interesting .Upload more videos.Our Support with you...

  • @yourbestsail
    @yourbestsail 7 หลายเดือนก่อน

    The standard flask session is stored client side, not server side.

  • @alexelwebman
    @alexelwebman 4 ปีที่แล้ว

    Nice tuts..Really appreciate your efforts. It makes Python on the web feel like a breeze. Thanks a lot Tim!

  • @MrPinkAds
    @MrPinkAds 2 ปีที่แล้ว

    Tim is so awesome! Have no words to describe! Thanks mate!

  • @edwardgaming5681
    @edwardgaming5681 3 ปีที่แล้ว

    Your skills are just amazing for beginners ❤️❤️❤️ love from india

  • @michealhall7776
    @michealhall7776 4 ปีที่แล้ว +19

    Tim I believe the session is stored on the browser, and is encrypted with the secret key. They browser sends the session with the request.

    • @HOPEDACODER
      @HOPEDACODER 11 หลายเดือนก่อน

      Is it a Cookie that's stored on the browser and Sessions on the server?🤔

  • @Darkev77
    @Darkev77 2 ปีที่แล้ว +2

    In 5:00, what’s the difference between redirected back to the login page “return redirect(url_for(login))” v.s rendering the login page via “render_template(‘login.html’)”?

  • @pugazhonline
    @pugazhonline 4 ปีที่แล้ว

    Tim, flask series is excellent. And very much helpful.

  • @canklc5772
    @canklc5772 2 ปีที่แล้ว

    Thanks Tim. You are a life-saver bro!

  • @servicer6969
    @servicer6969 4 ปีที่แล้ว

    I am so happy that this got recommended to me

  • @imadoulhou7854
    @imadoulhou7854 4 ปีที่แล้ว +1

    awesome again! kindly keep making advanced Flask tutorials...

  • @hemanthadawale4356
    @hemanthadawale4356 4 ปีที่แล้ว +12

    Hi Tim, this is great but these sessions are for client side storage (cookies) , can you tell us how to use server side session. Because client side sessions have a very small size limit. I want to store a dataframe in sessions. Can you tell something about the same?

    • @Aleks-kx3zj
      @Aleks-kx3zj ปีที่แล้ว

      Save a dataframe in sessions? Sessions are ideal for strings or numbers, but not for a whole dataframe. A dataframe you can store in a database for example.

  • @marcinajman6256
    @marcinajman6256 2 ปีที่แล้ว

    Thats exacly what I was looking for!

  • @meronapaw
    @meronapaw 4 ปีที่แล้ว

    The best teacher

  • @TheBrokenStudios1
    @TheBrokenStudios1 ปีที่แล้ว

    You just saved my day! Thanks man.

  • @DarrenSemotiuk
    @DarrenSemotiuk ปีที่แล้ว +1

    Awesome content. Parts 1-5 have a TEXT version which I prefer over just plain video. Are parts 6+ going to have a text version too? Seems they aren't linked after part 5.

  • @Python_Programmer798
    @Python_Programmer798 4 หลายเดือนก่อน

    Hey Tim i'm your regular viewer because your's way of teaching is so simple and to the point but in this video you have done something which is very confusing that you have created a variable and a function with same name "user" and it's confusing to understand that where you are using function and where you're using var

  • @teclote
    @teclote 10 หลายเดือนก่อน

    Outstanding, very clear, thank you.

  • @chrisgousset8673
    @chrisgousset8673 2 ปีที่แล้ว

    Great video and super helpful, thank you a ton Tim!

  • @intothevode
    @intothevode 2 ปีที่แล้ว

    Ye... im going to read all flask docs... hey better idea!! lets just chill and let tim explain that for us :D!!! THANKS TIM THANK YOU VERY MUCH, PEACE!

  • @arturgolata1
    @arturgolata1 2 ปีที่แล้ว

    Thank's Tim. Great tutorial

  • @gautiere-d9012
    @gautiere-d9012 3 ปีที่แล้ว

    Thanks for all your work, really good contents

  • @GLocarso
    @GLocarso 3 ปีที่แล้ว

    Thanks! you save my life from headache :)

  • @akinsnath7690
    @akinsnath7690 2 ปีที่แล้ว

    This video just saved me ... Thank you so

  • @dzmitryk9658
    @dzmitryk9658 2 ปีที่แล้ว

    Thank you for making these!

  • @itzamir3518
    @itzamir3518 3 ปีที่แล้ว

    Thanks man really appreciate your tutorial

  • @tymothylim6550
    @tymothylim6550 3 ปีที่แล้ว

    Thank you very much for this video! I learnt a lot from this :)

  • @martialnageshwar8867
    @martialnageshwar8867 3 ปีที่แล้ว

    Thanks Tim, it helps me alot!

  • @ppl_call_me_tima
    @ppl_call_me_tima 9 วันที่ผ่านมา

    really easy thanks!

  • @ironF5
    @ironF5 2 ปีที่แล้ว +2

    it was not working at my end... and how is this session different from flask_session? would be nice if u run 2 app side by side explaining this.... which one to prefer session or flask_session?

  • @salvadorhernandez2987
    @salvadorhernandez2987 2 ปีที่แล้ว

    very useful! thanks mate

  • @almamanley
    @almamanley 4 ปีที่แล้ว +2

    But is session stored in the server? Is that a new thing? I know of Flask-Session which is used for making it server side, but maybe that's superfluous now?
    Great video btw, very clear and useful.

    • @sammckel
      @sammckel 3 ปีที่แล้ว

      The video is incorrect, the session data in this tutorial is stored client side. the server encrypts it with the secret key and it is pas
      sed from the client to the server with every request.

  • @LiveAndLaugh524
    @LiveAndLaugh524 5 หลายเดือนก่อน

    So far Im loving backend more than frontend

  • @shadowreaper5413
    @shadowreaper5413 3 ปีที่แล้ว

    I think this is exactly what i need for missing the first 8 weeks of lectures and work from my university lmao.

  • @akshaysutar8275
    @akshaysutar8275 2 ปีที่แล้ว

    Thanks 😊 really helpful

  • @fd4002
    @fd4002 3 ปีที่แล้ว

    great video tim

  • @KevinHoltabc
    @KevinHoltabc 4 ปีที่แล้ว

    Amazing video, thank you!

  • @minecraft4life688
    @minecraft4life688 4 ปีที่แล้ว

    really helpful tutorial
    thanks

  • @neerajgupta8241
    @neerajgupta8241 3 ปีที่แล้ว

    Very Good tutorial

  • @RavingPain
    @RavingPain 4 ปีที่แล้ว +2

    I just watched your flappy bird video and I have a question. How did you learn ml ? Did you have it in uni or did you just learn it by yourself? I learned the basics of python on my own but when I tried to dabble into ml I got discouraged. It seemed like only a person that that is in computer engineering at uni could truly understand ml. Is there any hope for self teaching ml? And thanks for the amazing videos btw.

    • @Nada-yc8uo
      @Nada-yc8uo 4 ปีที่แล้ว

      I know you did not ask me :>
      but I think it is not about uni, at my uni even though im a cs major they didn't teach me much, I believe it depends on you.
      they did teach us math as a separate course, and basics ml but they didn't link it together so it was useless at the time.

  • @nowyouknow2249
    @nowyouknow2249 4 ปีที่แล้ว

    Nice one Tim!

  • @balloney2175
    @balloney2175 ปีที่แล้ว

    Hey Tim, I enjoy your tutorial but I have to lower the speed from normal to 0.75. English is my 3rd language.

  • @CARLOSRAMIREZ-kb4hp
    @CARLOSRAMIREZ-kb4hp 3 ปีที่แล้ว

    nice and very helpful

  • @HubertRozmarynowski
    @HubertRozmarynowski 2 ปีที่แล้ว

    This is a really good tutorial overall, but I think the permanent session was poorly explained.
    My website behaves in a different way than you described.
    Before the session variable was imported from flask, I stayed logged in unless I manually changed the url to /logout or closed the flask app. For example I could close the browser, reopen and do different things on the website or do nothing and still would be logged in.
    After importing the session variable and setting the value of app.permanent_session_lifetime to timedelta(seconds=10) for testing purposes, I got the following result.
    After logging in, every GET request resets the timer. For example, I can close the browser for 9 seconds, than open it up quickly before the session is lost, and then refresh every 9 seconds to stay logged in.

  • @karmic-brands
    @karmic-brands ปีที่แล้ว

    Don't store anything that really needs to be secure/private in the session key, as they are simply base64 encoded and easily deciphered/exposed. However, if the value is altered {"user":"mary"}, re-encoded in base64 and then the session cookie value edited, the session will become invalid (this is good), kindof like JWT.

  • @playonce4186
    @playonce4186 2 ปีที่แล้ว

    I love you brov i never understood how get post sessions worked

  • @ironF5
    @ironF5 2 ปีที่แล้ว

    if you press backspace after logout, you land back to the accounts page.... why? logically we should not be able to go back to account page after logout, but this code lets u the access after pressing backspace

  • @coding_dunes
    @coding_dunes 4 ปีที่แล้ว +3

    Back button returns to session even after logout
    Please help me

  • @chetansoni8620
    @chetansoni8620 4 ปีที่แล้ว +4

    Sir my session is not deleted when i closed browser and open again...Session stored the value permanantly and also i am not used app.permanent_session_lifetime yet.?? please help me to solve this issue.

    • @bpm.coding
      @bpm.coding 4 ปีที่แล้ว +1

      I do believe this is because Flask has been updated. If you restart the server it will still redirect you to /user with the correct information. If you restart the server and change the secret key it will then forget your session. This is not an issue, for it is actually a feature.

    • @darthvader4899
      @darthvader4899 4 ปีที่แล้ว

      did you close browser or did you close the tab

    • @bpm.coding
      @bpm.coding 4 ปีที่แล้ว +3

      @@darthvader4899 you might be 3 months late

    • @darthvader4899
      @darthvader4899 4 ปีที่แล้ว

      BPMPlayz you are right lol. Anyways i just wanted to comment :)

    • @bpm.coding
      @bpm.coding 4 ปีที่แล้ว

      hahaha

  • @xyx4641
    @xyx4641 3 ปีที่แล้ว

    Love u bro

  • @ashif-anoop8062
    @ashif-anoop8062 3 ปีที่แล้ว

    this is very helpfull ,can you say how to add one more field that would be very very more helpfull than.

  • @mzakyr342
    @mzakyr342 3 ปีที่แล้ว

    waw so good thnkyou

  • @scotter
    @scotter ปีที่แล้ว

    So cookies not needed? Done in background when you use session object?

  • @dennisasamoah2213
    @dennisasamoah2213 4 ปีที่แล้ว

    great stuff

  • @basavarajpatil9821
    @basavarajpatil9821 4 ปีที่แล้ว

    thanku man keep coding

  • @JoseHernandez-qk5by
    @JoseHernandez-qk5by ปีที่แล้ว

    Hi Tim
    1... Is it possible to have a secret_key for each session????
    2... Let's say my session's diccionay has more than 2 elements being "user" one of them ... by using session.pop("user", None) I will erase the whole session or just the element "user" in its diccionary?

  • @mark-pw1xf
    @mark-pw1xf 3 ปีที่แล้ว

    awesome!

  • @igalram1438
    @igalram1438 3 ปีที่แล้ว

    Thanks for this! I'm playing with sessions, trying to increment a session variable (day counter, for instance) by 1 with every POST request, but for some reason it is NOT kept in the session's "memory" for the next "POST". What am I doing wrong? Is Sessions the way to go about it, or do I need a DB?

  • @polargaiming7289
    @polargaiming7289 3 ปีที่แล้ว +1

    is not workin if i try to run it it shows me an error

  • @s0s1sk4_v_teste8
    @s0s1sk4_v_teste8 3 ปีที่แล้ว

    thx, very usefull

    • @Kevin-cy2dr
      @Kevin-cy2dr 3 ปีที่แล้ว

      Your pfp looks delicious😋😋

  • @AJXD2
    @AJXD2 ปีที่แล้ว

    i was screwing around with the login page and i found a vulnerability. if you type alert("Hello World!") it will pop up on the page an alert using javascript

  • @farhodubaydullaev7052
    @farhodubaydullaev7052 4 ปีที่แล้ว +2

    What language you did use to create website techwithtim.net

    • @rumexcrispus
      @rumexcrispus 4 ปีที่แล้ว

      That is obviously a wordpress site.

  • @hnehme
    @hnehme 3 ปีที่แล้ว

    Hello Tim, thank you for the tutorial, do you have any tutorial about Flask Authenticating Using JSON Web Tokens, if not is it possible to create one for us? Thanks.

  • @abdulfetadedgba3414
    @abdulfetadedgba3414 3 ปีที่แล้ว

    best tnx

  • @AnopSinghRanawatperl
    @AnopSinghRanawatperl 3 ปีที่แล้ว

    thanks bro :)

  • @yoolhomie2566
    @yoolhomie2566 3 ปีที่แล้ว

    Hey Tim, I'd like to know if its possible to create an alert when the session timeout occurs, for example a prompt alert stating that, "You have been logged out". How do you go about doing it? Thanks.

  • @user-tz3di7he8f
    @user-tz3di7he8f 4 ปีที่แล้ว

    Hi tim, just one question. Since the python file is basically the server (right?), does everyone who goes to your webpage basically get handed this code or is there just one version of this code that everyone goes to

    • @TechWithTim
      @TechWithTim  4 ปีที่แล้ว +1

      They don’t have access to the code

  • @claudiogalinha
    @claudiogalinha 3 ปีที่แล้ว

    Obrigado

  • @pr02640
    @pr02640 4 ปีที่แล้ว

    Can someone please explain more on the secret key. I am unable to find its usage and how a random secret keys makes a difference, than having no key at all?

  • @-0-__-0-
    @-0-__-0- ปีที่แล้ว

    Would it be ok to place an instance of a class in a session? Like I have a quiz web app and I want all the routes to be able to communicate with each other by using a class. I don't want to just initialize the class because then, a lot of users will be using the same class. So I thought of creating an instance inside a route, placing it inside a session and getting that session in a different route? Is that safe?

  • @user-ng4bc3cv6g
    @user-ng4bc3cv6g 3 ปีที่แล้ว +1

    I have a question, can we put more than an element in the session if I have more than a single information like storing both name and password? Or I should create an another session that contains password.

    • @blazi_0
      @blazi_0 3 ปีที่แล้ว +1

      ofcourse u can

  • @saikrishnadyavarasetti7833
    @saikrishnadyavarasetti7833 4 ปีที่แล้ว

    Hey Tim, can you help me with flask+webcam+socketio? Any example tutorial to understand and club them so that each user can launch the app and give the data

  • @WaldoTheWombat
    @WaldoTheWombat 3 ปีที่แล้ว

    So is there some file being stored in the project which indicates the session's creation time and the time it should last or will is this just a run time parameter cause the server shouldn't even stop running?

  • @codingwithanish4681
    @codingwithanish4681 3 ปีที่แล้ว

    For some reason, when I open the web again, if I have logged in with my name then the user page still displays my name!!

  • @anukooldwivedi4025
    @anukooldwivedi4025 4 ปีที่แล้ว

    How to handle the case when different users logged in from different computers then how to separate the users

  • @santiagoandresortiz5563
    @santiagoandresortiz5563 2 ปีที่แล้ว +1

    i followed this video every step of the way and found an issue....when i close my browser...the session stil remains....help please

  • @ComputerTest-od9gs
    @ComputerTest-od9gs ปีที่แล้ว

    Hi, can you explain, how to shut down the development / built-in server of flask without using ctrl+c? Is there a way to code it in the python script?

  • @tonyiommisg
    @tonyiommisg 3 ปีที่แล้ว

    How does one pass session from one python file to another and can it be used with WTForms? Right now I'd like to pass information from one page to the next and have info from a form go to session and then pass that to make a database query. Thanks!

  • @joe62994
    @joe62994 3 ปีที่แล้ว

    Please are you using a private browser. Because it seems flask stores sessions as cookies on the browser which are still persistent even after the browser is closed in my case