Login htpasswd via CURL and keep the session in browser
You can use $_SESSION, i.e....
//put this in the top of your phpsession_start();//then store the user and password in the session...$_SESSION['username'] = 'username';$_SESSION['password'] = 'password';// replace in your code anywhere the $username and $password variables // with the new $_SESSION['username'] and $_SESSION['password']
Finally I could solve this. Although it is not a very secure method, it is a good solution for my problem.
Thanks to Aberel I started to investigate around cookies and the http auth. After that I'm able to set a cookie with PHP (or with JS, there are no differences) and check it with the .htaccess in each folder. The .htaccess looks like this:
AuthUserFile /path/.htpasswdAuthName "Forbidden"AuthType BasicSetEnvIfNoCase Cookie COOKIENAME = randomHash $ PASS = 1Require valid-user#Allow valid-userOrder Deny, AllowDeny from allAllow from env = PASSSatisfy any
The COOKIENAME can be anything and the randomHash you identify each user.
Thanks for the help