When I try to connect via https, I can log in, but then my connection is redirected back to http. What can cause this behavior? ΒΆ

This is caused by the fact that PHP scripts have no knowledge that the site is using https. Depending on used webserver, you should configure it to let PHP know about URL and scheme used to access it.

For example in Apache ensure that you have enabled SSLOptions and StdEnvVars in the configuration.

See also

<https://httpd.apache.org/docs/2.4/mod/mod_ssl.html>