Ask coding questions

← Back to all posts
How To Make A Login System?
GameDev46 (203)

This question has probably been one of the hardest for me to solve, but I am still stuck as I need a way to save the login data of users to be remembered forever (I know about local storage, but that can be incredibly unreliable as it will just disappear the next time you come back)

So what I am asking is if anyone knows how to do a login system that works for JavaScript, then please help me and the others who look at this post. Thanks!

Answered by nbbcsf (23) [earned 5 cycles]
View Answer
Comments
hotnewtop
nbbcsf (23)

LocalStorage is not for logins. Your question is unbelievably complicated. If you look at one my earliest repls, (chat), I implemented a very secure login function.

Steps to make a login:
1. You need a frontend AND a backend. Backend could be PHP, Ruby, Node.js, Python, Java, or something else. Frontend would be HTML, CSS and JavaScript.
2. Set up a database: mySQL, MongoDB, SQLite, etc. YOu need this for storing your user information
3. Every time a user signs up, insert the information in the database. Make sure you hash the password. When they login, check for their entry in the database. If it is found, set a session in the user's computer that he is logged in, OR use JWT.

Seriously, creating a login is UNBELIEVABLY complicated.

EpicGamer007 (1765)

@nbbcsf good answer. And yes, I must stress it is incredibly complicated. Getting JWT/Sessions to work is time consuming as well as the database. If you want a way to authenticate users, your best bet is to use some external form of authentication like repl_auth, github auth, or google auth.

FlipLeigion (4)
<SCRIPT LANGUAGE="JavaScript"> function Getstats() { window.status=('Attempting to Login to user area.') var AccId; var iName; AccId = document.iAccInput.iAccID.value iName = document.iAccInput.iName.value if (AccId == "" || iName == "") { alert('\nERROR\nYou must enter ALL Details,\nto View your statistics.\n'); window.status=('Missing data or Invalid. Check spelling and Ensure Names are in Correct Case.') } else { var location=(iName + ".html"); this.location.href = location; window.status=(' Verifying: ' + iName +' Please wait........'); } } </SCRIPT><hr><FORM NAME="iAccInput"> <CENTER> <TABLE BORDER="1px" bordercolor="#c0c0c0" cellpadding="5" cellspacing="0"> <TR> <TD ALIGN="RIGHT"> <p><FONT SIZE="3" FACE="Arial"><B>User Name:</B></FONT> </p></td>
    <TD>
        <INPUT TYPE="TEXT" NAME="iName" MAXLENGTH="15">
    </td>
    <TD> &nbsp;
    </td>
</tr>
<tr>
    <TD ALIGN="RIGHT">

        <p><FONT SIZE="3" FACE="Arial"><B>Password:</B></FONT>
          </p></TD>
    <td>
        <INPUT NAME="iAccID" MAXLENGTH="15" HEIGHT="50">
    </TD>
    <td align="center">
        <INPUT TYPE="BUTTON" VALUE=" Login " onClick="Getstats()" HEIGHT="40" WIDTH="50"><BR><br>
        <INPUT TYPE="RESET" VALUE=" Reset " onClick="window.status=('RESET: Please enter your USERNAME and ACCOUNT ID.')" WIDTH="50">

    </td>
</TR>
</TABLE>

that mighhhhhhhhht work. sorry if u cant read it

L0k3d20uz4 (1)

I don't really work a lot with javascript so this could be a dumb question but are you working with an html webpage?