[TYPO3] Autologin problems

Eduard Renger eduard at renger.info
Wed Mar 8 09:44:29 CET 2006


Well I think I solved the puzzle with a very quick and dirty solution.
I'll just post it here since there have been quite a lot of questions
about this on the list and I haven't seen an answer to it so far.

What I did was the following. I have installed the arotea_loginbox
extension. That extension allows you to template the newloginbox. I then
added the autologin checkbox in the template like this:

<input  type="hidden" name="autologin" value="0"><input
id="login_remember" type="checkbox" name="autologin" value="1">

Then I replaced the following code inside the file
arotea_loginbox/pi1/class.tx_arotealoginbox_pi1.php:
if($GLOBALS["TSFE"]->loginUser) {
			$templateMarker = "###TEMPLATE_LOGOUT###";
		}

with:

if($GLOBALS["TSFE"]->loginUser) {
			$templateMarker = "###TEMPLATE_LOGOUT###";
			$cookie_value = $_COOKIE['fe_typo_user'];
			if (isset($_POST['autologin']))
			{
				if ($_POST['autologin'] == 1)
				{
					setcookie("fe_typo_user", $cookie_value, time()+31536000);
				}
				else
				{
					setcookie("fe_typo_user", $cookie_value, 0);
				}
			}
		}

That will let the cookie expire after a year I think. Just change the
31536000 to whatever you want. I'm sure it would be possible to get this
value from some setup parameter but I have no idea how.

I know it's quick and dirty but I hope this is of some help to somebody.
Oh I also have the extension c3bi_cookie_at_login installed, otherwise I
think the cookie would be overwritten everytime you load a page. This c3bi
extension makes sure the cookie is only written at login. I also have not
set the lifetime TSconfig value.

Cheers,
Eduard

> I want to enable the auto login feature on my website by including a
> checkbox below the login button. I've read many posts about how it should
> be done and I think I did it right, but for some reason when I login and
> go to another page I get logged off again.




More information about the TYPO3-english mailing list