How To Save User Logins And Retrieve It On Next Visit

how to save logins to database and retrieve it on next visit?

It is not clear what do you mean. Please clarify in more details

I'm looking for a way to let users save their login details so they don't have to enter it on next visit

Can only be done via the user's browser. How would you associate the user with their account?

I'm able to acheive this with cookie and local storage, but they are too open and can be accessed by anyone using the computer, but i want to save the info in the database or on session

You can always encrypt the cookie using a key that is only known within the cart. I.e. you could use fn_encrypt_text()/fn_decrypt_text() functions on the cookie data. But note that cookies have a lifetime and many users clear them regularly. Not sure the benefit outweighs the risk/cost.

You can always encrypt the cookie using a key that is only known within the cart. I.e. you could use fn_encrypt_text()/fn_decrypt_text() functions on the cookie data. But note that cookies have a lifetime and many users clear them regularly. Not sure the benefit outweighs the risk/cost.

How can i use this to set a cookie please

Cookies.set('password', fn_encrypt_text());

Cookies.get(fn_decrypt_text());

I tried it but it's not working this way

It appears you are using JS. The fn_encrypt_text/fn_decripty_text are PHP function.

Suggest you use the PHP methods to set/get the cookie values. I.e. to set, follow: https://www.php.net/manual/en/function.setcookie.php

To get, use $_COOKIES['password'] assuming the cookie name is 'password'.