<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jotlab &#187; persistent</title>
	<atom:link href="http://www.jotlab.com/tag/persistent/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jotlab.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Fri, 22 Mar 2013 01:15:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Remember Me: A CakePHP Persistent Login Plugin</title>
		<link>http://www.jotlab.com/2011/remember-me-another-cakephp-persistent-login-plugin</link>
		<comments>http://www.jotlab.com/2011/remember-me-another-cakephp-persistent-login-plugin#comments</comments>
		<pubDate>Tue, 06 Sep 2011 10:36:11 +0000</pubDate>
		<dc:creator>voidet</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[me]]></category>
		<category><![CDATA[persistent]]></category>
		<category><![CDATA[remember]]></category>
		<category><![CDATA[remember me]]></category>
		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://www.jotlab.com/?p=4663</guid>
		<description><![CDATA[After creating numerous CMS&#8217;s and getting client questions asking how come they don&#8217;t get automatically logged into their administration panel after 2 months of inactivity I decided to make Yet Another Remember Me Plugin (YARMP) &#8211; Yeh, I made that acronym up, it happens. Why... <span><a href="http://www.jotlab.com/2011/remember-me-another-cakephp-persistent-login-plugin" title="Remember Me: A CakePHP Persistent Login Plugin" rel="bookmark">[+]</a></span>]]></description>
				<content:encoded><![CDATA[<p>After creating numerous CMS&#8217;s and getting client questions asking how come they don&#8217;t get automatically logged into their administration panel after 2 months of inactivity I decided to make Yet Another Remember Me Plugin (YARMP) &#8211; Yeh, I made that acronym up, it happens.</p>
<h2>Why Remember Me</h2>
<p>Remember me isn&#8217;t just a standard set a cookie and run with it type persistent login handler. Instead remember me uses salted tokens alongside the user&#8217;s auto login cookie to protect against session hijacking. The basic gist of the cycle is that a user is given a cookie with a unique set of authentication tokens. When a new login is made these tokens change, and if the user who presents a cookie to renew a session does no longer comply with these tokens, they&#8217;re denied and all cookies and sessions are flushed out!</p>
<p>What is different from this plugin to that of the others I find on google? Well RememberMe is secure, as secure as the word can be when written on the internet. It uses a token for its authenticity which is salted to ensure no cookie hijacking is possible. It is also extremely easy to set up. Just clone the plugin, add it to your app controller, add in one line to your login method and add a checkbox to your form. You&#8217;ll then have tasty cookies remembering your authenticated users with extremely minimal risk of cookie hijacking.</p>
<h2>Installing Remember Me</h2>
<p>First watch <a href="http://www.youtube.com/watch?v=GGIeJswiJU4">this</a>. Now install Remember me as a plugin through GitHub:</p>
<p><strong>Github:</strong> <a href="https://github.com/voidet/remember_me">https://github.com/voidet/remember_me</a></p>
<pre class="brush: php; title: ; notranslate">cd myapp
git clone git://github.com/voidet/remember_me.git remember_me</pre>
<p>or if you&#8217;re using submodules which you should be:</p>
<pre class="brush: php; title: ; notranslate">cd myapp
git submodule add git://github.com/voidet/remember_me.git app/plugins/remember_me
git submodule init
git submodule update</pre>
<p>You will also need to add two fields in your database that you use for user auth. The default names are token and token_salt. You can override which is shown in the next section.</p>
<p>From there it is a matter of adding it into your controller and ensuring you have your form fields linked up to what RememberMe is listening for.</p>
<h2>Adding Remember Me to your application</h2>
<p>Firstly you will need to add RememberMe to your controller, probably best to do this in app_controller.php so it is fired on all pages that use it:</p>
<pre class="brush: php; title: ; notranslate">var $components = array('RememberMe.RememberMe');</pre>
<p>After that you will need to tell RememberMe what form field you are using to activate the remember me function (like the name of a checkbox on a login screen that asks you if you want to be remembered for a while). The default is &#8220;remember_me&#8221; but if you want to change it you could do something like:</p>
<pre class="brush: php; title: ; notranslate">var $components = array('RememberMe.RememberMe' =&gt; array('field_name' =&gt; 'i_am_so_custom_it_hurts');</pre>
<p>Now add this field into your form and once posted you can set up the RememberMe cookie! Like:</p>
<pre class="brush: php; title: ; notranslate">function members_login() {
    if ($this-&gt;Auth-&gt;user()) {
        if (!empty($this-&gt;data)) {
            $this-&gt;RememberMe-&gt;setRememberMe($this-&gt;data[$this-&gt;Member-&gt;alias]);
        }
        $this-&gt;redirect($this-&gt;Auth-&gt;loginRedirect);
    }
}</pre>
<p>Of course this is an example. If you&#8217;re using auth remember to disable autoRedirect otherwise this action won&#8217;t be fired.</p>
<h2>Refresh my Cookie!</h2>
<p>A built in method comes with RememberMe. It is used to refresh the contents of the AuthCookie on page load, so it has the longest lifetime it can (without going outside the bounds of inactivity (which you set as a cookie setting)). To do so simply call:</p>
<pre class="brush: php; title: ; notranslate">if ($this-&gt;params['action'] != 'members_logout') {
        $this-&gt;RememberMe-&gt;checkUser();
    }</pre>
<p>This will refresh the cookie and log the user in if there is no Session available. Of course you don&#8217;t want to run this on logout methods, as you won&#8217;t be logged out!</p>
<h2>Feedback</h2>
<p>If you feel this plugin is missing something I would love to hear what you would like me to add in! But otherwise enjoy and please leave some feedback <img src='http://www.jotlab.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jotlab.com/2011/remember-me-another-cakephp-persistent-login-plugin/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
