Store login input text

Asked

Viewed 616 times

1

Guys I’m needing to record 2 fields from the login screen of my program, I want to give ease to the friend who has logged in, he does not need to type things like company code, and email. I tried to use the autocomplete but there was no functionality. Is there any language (HTML, CSS, JAVASCRIPT) that makes this easy or I have to create a method ?

I thought about saving in a cookie, where if you have it saved otherwise it did not save ?

I tried to set jquery autocomplete this way:

<script>
  jQuery('#codigo').attr('autocomplete','on');
  jQuery('#email').attr('autocomplete','on');
</script>

2 answers

2

SAVED IN SESSION IS SAFER!

$_SESSION["LOGIN"] = "VALOR";

Remember: SESSION will be saved only in the current session, by closing browser the session will delete.

Don’t forget to turn on the Session at the top of the script:

Code:

session_start();

If you prefer to save in cookie for a certain time is also ideal!

  • The problem of the session is precisely what you reported, I need something that is recorded, and I found the localstorage, I had already used it in my mobile applications, but I forgot its potential, more thank you for the suggestion !

  • I use cookie and session. The user who chooses to log in by checking a box: "Remind me", is saved in a cookie, otherwise saved in Sesssion.

1

The solution I found was much simpler than I thought it was, I used the localstorage technology, so I could save all the necessary data for my login.

        <script>
        var codigo = localStorage.getItem("codigo"),
                email = localStorage.getItem("email"),
                senha = localStorage.getItem("palavra");

        $("#codigo").val(codigo);
        $("#email").val(email);
        $("#palavra").val(senha);

        $("#entrar").click(function () {
            localStorage.setItem("codigo", $("#codigo").val());
            localStorage.setItem("email", $("#email").val());
            localStorage.setItem("palavra", $("#palavra").val());
        });

    </script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.