I am currently developing a website where I am facing the following problem:
I tried passing the User id and password to the login page and auto submit the page using a script, which will take the user to the next page. This is just to bypass the login page in my site. This works perfectly fine.
When the "No script" add on is enabled on a Mozilla Firefox开发者_如何学JAVA browser, the script to auto submit the form is not working. As a result, the login page is getting displayed to the user with the filled in user id and password.
Also, sometimes the user is able to see the login page on the front end when we auto submit the login page.
Are there any possible ways to overcome these two issues?
Redirecting the user's browser as you are doing now is really only possible client side with Javascript, which is always able to be blocked. You could store the user_id and password in a session variable and access that data on your login page which handle's the actual authentication. Doing it that way would eliminate the need for auto submitting forms.
But if you really want to use form posting you can emulate a form post with PHP using cURL, but this is a little more complicated.
cURL on php.net
Sending post form data with PHP and cURL
On my site, if the user is not logged in I run a "tryCookieAuthentication" method on every page load which checks to see if the "remember me" cookie is set. If it's set and everything seems legitimate, I go ahead and authenticate the user and log him in. This way the user doesn't even have to touch the login page. I don't know if this is what you're trying to do, but it might give you an idea.
If you already know the user_id and password when the user requests the login page then you could just send a location header
精彩评论