Jump to content

Protecting A Page

Recommended Posts

Hello,How would you protect a page from being accessed unless you authorize them? Such as, if they try to go to /login.php. If they try to access that page without first filling out the form on /login.html, give them an error. I've heard of something called mod_rewrite, however, I use a free host, so I don't have server access, so I can't, I think. Using Sessions wouldn't be the best way either.Thanks!

Link to post
Share on other sites

Using sessions is the best way. Set the username in the session when they login and check the session on every other page. If it's empty or you can't find the user in the database, then you redirect them back to the login page. You could also store a username and encrypted password in a cookie. You would need to save the encrypted password because if you just have the username someone could create a fake cookie. You don't need to do that with the session because a user can't control what is in the session.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...