Cookie in Javascript (login page design)
Earlier I posted a program and asked a question about handling cookies in Javascript. I posted one code and you can find it in my other question. Many gave good answers and I tried their solutions as well. But since I am new to this html and javascript, I may not know how to find errors and debug them.
So, can anyone post their solution for this problem. I want to create a web page where it has to check the cookie on load. If the cookie is 20 minutes older, it should go to the login page (ask for a username and password). Otherwise no login is required and it should go straight to one page (it's under development).
So, if anyone already has similar or exact code (as long as the cookie is maintained), volunteer to post it.
Chaithra relationship
a source to share
It looks like you are trying to implement a login system using javascript. If so, STOP . All forms of authentication must be done on the server side, and you can use sessions to determine how much time has passed since activity from that account. Client-side "cracking" (like javascript) is ridiculously easy.
a source to share
As nickf said, session timeout is best handled on the server side. The presence of a cookie is used to locate the session, not to implement a timeout. Session cookies are generally used to track session state, not those that expire. They persist as long as the browser is open.
On the server side, when processing a request, it uses a cookie value (usually a long random string that is difficult to guess) to find the user's session. If there is no session, it can respond with a redirect to the login page.
EDIT: In the comments you said, you're using goAhead - it's hard for me to access their wiki, but assuming it's close to Microsoft ASP, see this link from the webmaster-talk asp-forum for an example of how to handle login ... Part of the note on the login page:
session("UserID") = rs.Fields("usrName")
and the part that checks every page load is still good:
if (session("UserID") = "") then
response.redirect("default.asp")
This is, as I described in the notes below, controlling the server side timeout detection and letting the framework (goAhead in your case) do all the cookie magic and idle timeout magic.
a source to share
Short answer - This is a pretty good tutorial ... click here ...
The best answer. If you are going to build a login system, you need to understand cookies, sessions, forms, and security (injection !!!) before starting with anything that is implemented for serious use. You should know to avoid client side scripting for things like login before you start. I would recommend that you follow the tutorials. You might want to look at things like the difference between different languages and when is the best time to use them.
a source to share