Jump to content


Photo

autologin to .htaccess protected directory through php - how?


  • Please log in to reply
4 replies to this topic

#1 scotch33

scotch33
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 27 October 2006 - 10:19 AM

Hi,

I have a site where the user arrives and is asked to validate themselves.  If the validation is correct then the header of the  php page takes them to site version a, if not they are given the choice of going to site version b or leaving completely.

Thats all done ands working - now I want to password protect site version A (an oscommerce install with private member prices) which I am planning to do with .htaccess. 

Where I come unstuck is how to use php to send the .htaccess username and password in the header so that the user does not have to log in.  This is because users are members of groups that will know their group details but we don't ever want them to have the actual login and password to the protected directory.

Is there a was of doing this, or if not, is there a better way to protect the directory and then have the header/form auto login to the system.

Thanks!

John.
The arrogance with which someone answers your post is usually inversely proportional to the life they have out of web forums.
(Plato - honest!)

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 27 October 2006 - 10:56 AM

I think that the short answer is no.  It can be done the other way around, you can log into an .htaccess protected directory and automatically be authenticated with php, but not the other way around.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 scotch33

scotch33
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 30 October 2006 - 03:32 PM

That being the case - does anyone have any php password software / member area software that they can suggest as a good start?  one that I can auto login via hidden form fields in the header would be the sort of thing I am after.

Failing that I guess I can simply put an if query in the header of each 'memberpage' so that if the cookie I store on the user's pc containing a password etc will validate or if not will send them elsewhere.

Apart from the potential for users not accepting cookies can anyone see an issue with this method
The arrogance with which someone answers your post is usually inversely proportional to the life they have out of web forums.
(Plato - honest!)

#4 justhost

justhost
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 10 March 2007 - 01:04 AM

I think that the short answer is no.  It can be done the other way around, you can log into an .htaccess protected directory and automatically be authenticated with php, but not the other way around.

Regards
Huggie


Would you mind telling me how you would do this then?

This would work for what I am trying to do.

Thank you.

Keith G
Keith Gallant
[br]JustHosting.ca
[br]http://www.justhosting.ca

#5 mssakib

mssakib
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 28 December 2012 - 09:05 PM

thx guys.......




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users