Ask coding questions

← Back to all posts
How do I fix this login problem?
Muhammad_SJC (4)

I am trying to make a chat room but for that first i need a login menu. I'v coded this so far but i want the usernames and passwords to stay in the code forever, even if i stop and then run the code again. PLs help me.

Commentshotnewtop
ash15khng (306)

The previous 2 comments are about using text files and I'm going to explain why you wouldn't want to do this.
1) repl.it doesn't save generated text files, so if you use your code to generate a file it will get deleted afterwards, which defeats the purpose of it.
2) Even if repl.it does save the files, everyone looking at the repl would be able to see the passwords and everything.

A possible solution would be jsonstore.io, although I have no idea how to use it. (I've heard other replers using it)

mwilki7 (203)

@ash15khng it's saved my text files, and people that i've seen on this site who use text files usually encrypt the data

Muhammad_SJC (4)

@ash15khng Ok i'll ask people how to use jsonstore.io

Muhammad_SJC (4)

@ash15khng i've also heard people saying something about a pickle module

Muhammad_SJC (4)

@mwilki7 how do i look back at the login details and then confirm if its right?
I made a test code and it kinda works.
https://repl.it/@Muhammad_SJC/testing

ash15khng (306)

@mwilki7 Well one time I tried it doesn't save but idk about now.
EDIT: apparently now it does which is cool

ash15khng (306)

@Muhammad_SJC Nice, you just need to encrypt the passwords now (I have no idea how to)

RyanRana (168)

One thing you can do if store the values in the text file. Create two files, one for usernames (usernames.txt) and the other one for passwords(passwords.txt). After a new usearnames and password are created to add to the file. When checking a username and password exists check through the list. If you are not good with text files with python here is a couple of good resources to learn about it.
https://www.guru99.com/reading-and-writing-files-in-python.html
https://www.youtube.com/watch?v=Uh2ebFW8OYM
https://realpython.com/read-write-files-python/
https://www.pythonforbeginners.com/files/reading-and-writing-files-in-python
My favorite is the guru99 site. Also, if you need additional help specifically on this project just ask me below. If this post helped please like it. :)

Muhammad_SJC (4)

@RyanRana Can you pls join in my multiplayer and make some changes in my code?
I'm a beginner

RyanRana (168)

@Muhammad_SJC I took a look, your style of coding is a little different than mine. That does not mean it's bad, everybody has a style of coding just like writing. For me, it is a little weird to work on this code just because the format is not usual for me. Thanks for the offer though, but you should try first on your own if you need really specific things than you can ask me.

mwilki7 (203)

store them in a text file