<?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>Inspire Labs &#187; Adam Pancutt</title>
	<atom:link href="http://www.inspirelabs.co.uk/author/apancutt/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.inspirelabs.co.uk</link>
	<description>Updates from Inspire Digital at IPC Media</description>
	<lastBuildDate>Wed, 05 Oct 2011 14:03:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Out with the Old, In with the New</title>
		<link>http://www.inspirelabs.co.uk/22/03/2010/out-with-the-old-in-with-the-new/</link>
		<comments>http://www.inspirelabs.co.uk/22/03/2010/out-with-the-old-in-with-the-new/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 17:38:55 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Team News]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=209</guid>
		<description><![CDATA[So Ladley decided to leave us. Boo! He&#8217;s a bit of a greedy guy that one; someone with a finger in almost every pie. From starting out as the Team Leader of the Southbank division he eventually ended up in the greatness that is Inspire. After nearly three years at IPC he heads for pastures [...]]]></description>
			<content:encoded><![CDATA[<p>So Ladley decided to leave us. Boo! He&#8217;s a bit of a greedy guy that one; someone with a finger in almost every pie. From starting out as the Team Leader of the Southbank division he eventually ended up in the greatness that is Inspire. After nearly three years at IPC he heads for pastures new, and good luck to him!</p>
<p>On the flip-side, today we introduce to you Mr Peter Chamberlin! Chambers, or Cham for short and C for shorter (and to avoid confusion with the Jankers) is our latest recruit. A photo will be available for you to admire soon but for now, an applause will do&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/22/03/2010/out-with-the-old-in-with-the-new/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YUI3: My First Experience</title>
		<link>http://www.inspirelabs.co.uk/16/02/2010/yui3-my-first-experience/</link>
		<comments>http://www.inspirelabs.co.uk/16/02/2010/yui3-my-first-experience/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 09:29:55 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=176</guid>
		<description><![CDATA[With the Yahoo! User Interface (YUI) javascript library now the library of choice at IPC I thought it was about time to start playing with it. Background to Javascript Frameworks My first experience of a javascript library was to build a debug console for my framework. Version one of the console was built in jQuery [...]]]></description>
			<content:encoded><![CDATA[<p>With the Yahoo! User Interface (YUI) javascript library now the library of choice at IPC I thought it was about time to start playing with it.</p>
<h2>Background to Javascript Frameworks</h2>
<p>My first experience of a javascript <em>library </em>was to build a debug console for <a href="http://framework.pixelinx.co.uk" target="_blank">my framework</a>. Version one of the console was built in jQuery (v1.2, I think). I liked it. I liked how you no longer needed to repeat the same cross-browser checks every time you built something new; how effects were easy to acheive without having to create your own; chaining. Most importantly, though, I liked how the library made the development experience a little more unified.</p>
<h2>First Taste of YUI</h2>
<p>A few months later I decided to migrate the jQuery console to <a href="http://developer.yahoo.com/yui/2/" target="_blank">YUI2</a>. I quickly found that the <a href="http://developer.yahoo.com/yui/docs/" target="_blank">documentation</a> was not brilliant for new-comers (and still isn&#8217;t). My migration, although worked, was not how YUI2 intended a widget to be built. Overall, it took me a lot longer to learn YUI2 than jQuery and I put this mostly down to the documentation (<a href="http://api.jquery.com/" target="_blank">jQuery API docs</a> are brilliant) though also because jQuery tutorials are abundant as are community plugins which you can rip apart to assist your learning.</p>
<h2>Upgrading to YUI3</h2>
<p>Last week I decided to have a go at upgrading the console to <a href="http://developer.yahoo.com/yui/3/" target="_blank">YUI3</a>. Once again, the <a href="http://developer.yahoo.com/yui/3/api/" target="_blank">documentation</a> was pretty poor for new-comers but at least this time at least I had a foundation to work with. This time I wanted to do things right. I wanted to extend the YUI Widget class and do things how YUI wanted me to do things. Just a week later, it&#8217;s done.</p>
<h2>Benefits of YUI3</h2>
<p>I couldn&#8217;t give you a fair comparison between jQuery and YUI, or advise you on which is the best for your project, as I&#8217;ve not kept up with the progress of jQuery. However, I&#8217;m happy YUI is the IPC standard as it&#8217;s something I&#8217;ve had a lot of fun learning and playing with.</p>
<p>Key components of YUI3 that I&#8217;ve come to love are:</p>
<ul>
<li><a href="http://developer.yahoo.com/yui/3/yui/#loader" target="_blank">Loader</a></li>
<li><a href="http://developer.yahoo.com/yui/3/widget/" target="_blank">Widget</a></li>
<li><a href="http://developer.yahoo.com/yui/3/attribute/" target="_blank">Attribute</a></li>
<li><a href="http://developer.yahoo.com/yui/3/event/" target="_blank">Event</a></li>
<li><a href="http://developer.yahoo.com/yui/3/node/">Node</a>, specifically their consideration for <a href="http://developer.yahoo.com/yui/3/node/#node-aria">WAI-ARIA</a> support and <a href="http://developer.yahoo.com/yui/3/node/#node-query">Node Queries/CSS3 Selectors</a></li>
</ul>
<p>Next, to get the most out of YUI3, I need to look into:</p>
<ol>
<li><a href="http://developer.yahoo.com/yui/3/profiler/" target="_blank">Profiler</a></li>
<li><a href="http://developer.yahoo.com/yui/3/test/" target="_blank">Test</a></li>
<li>&#8230;and the other many utilities available</li>
</ol>
<h2>Summary</h2>
<p>In summary, once you&#8217;ve grasped YUI and put together your first widget you&#8217;ll feel like you&#8217;ve acheived something a lot more pure, legible and stable than you do with jQuery. Or at least I do.</p>
<h2>More to Come</h2>
<p>Over the next few days I hope to put together some tutorials to assist people with their first YUI widget. It&#8217;s been a struggle for me to find the help I needed so, hopefully, I can help a few of you out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/16/02/2010/yui3-my-first-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixelinx Framework</title>
		<link>http://www.inspirelabs.co.uk/19/11/2009/pixelinx-framework/</link>
		<comments>http://www.inspirelabs.co.uk/19/11/2009/pixelinx-framework/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 11:23:50 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=153</guid>
		<description><![CDATA[The Pixelinx Framework is something I&#8217;ve been having a play around with over the past year. It&#8217;s still in relatively early stages but it&#8217;s something I&#8217;m taking more seriously, and have recently open-sourced. Take a look.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://framework.pixelinx.co.uk" target="_blank">Pixelinx Framework</a> is something I&#8217;ve been having a play around with over the past year. It&#8217;s still in relatively early stages but it&#8217;s something I&#8217;m taking more seriously, and have recently open-sourced.</p>
<p><a href="http://framework.pixelinx.co.uk" target="_blank">Take a look</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/19/11/2009/pixelinx-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Some New Beta Sites</title>
		<link>http://www.inspirelabs.co.uk/06/08/2009/introducing-some-new-beta-sites/</link>
		<comments>http://www.inspirelabs.co.uk/06/08/2009/introducing-some-new-beta-sites/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 11:08:51 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Team News]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=146</guid>
		<description><![CDATA[The last few months have been pretty hectic here in Inspire. After losing two developers, we&#8217;ve had to work extra hard to deliver on our promises of nine new websites. Naturally, we were successful. As with all new rebuilds, we have launched these new sites as &#8216;beta&#8217;, running parallel with the existing sites. Check them [...]]]></description>
			<content:encoded><![CDATA[<p>The last few months have been pretty hectic here in Inspire. After losing two developers, we&#8217;ve had to work extra hard to deliver on our promises of nine new websites.</p>
<p>Naturally, we were successful.</p>
<p>As with all new rebuilds, we have launched these new sites as &#8216;beta&#8217;, running parallel with the existing sites. Check them out and let us know what you think!</p>
<ol>
<li>
		<a href="http://beta.webuser.co.uk" target="_blank">http://beta.webuser.co.uk</a><br />
		Currently <a href="http://www.webuser.co.uk" target="_blank">http://www.webuser.co.uk</a>
	</li>
<li>
		<a href="http://beta.ybw.com" target="_blank">http://beta.ybw.com</a><br />
		Currently <a href="http://www.ybw.com" target="_blank">http://www.ybw.com</a>
	</li>
<li>
		<a href="http://beta.classicboat.co.uk" target="_blank">http://beta.classicboat.co.uk</a><br />
		Currently <a href="http://www.classicboat.co.uk/cb/home.htm" target="_blank">http://www.classicboat.co.uk/cb/home.htm</a>
	</li>
<li>
		<a href="http://beta.mbmclub.com" target="_blank">http://beta.mbmclub.com</a><br />
		Currently <a href="http://www.mbmclub.com/mbm/home.htm" target="_blank">http://www.mbmclub.com/mbm/home.htm</a>
	</li>
<li>
		<a href="http://beta.mby.com" target="_blank">http://beta.mby.com</a><br />
		Currently <a href="http://www.mby.com/mby/home.htm" target="_blank">http://www.mby.com/mby/home.htm</a>
	</li>
<li>
		<a href="http://beta.pbo.co.uk" target="_blank">http://beta.pbo.co.uk</a><br />
		Currently <a href="http://www.pbo.co.uk/pbo/home.htm" target="_blank">http://www.pbo.co.uk/pbo/home.htm</a>
	</li>
<li>
		<a href="http://beta.shipsmonthly.com" target="_blank">http://beta.shipsmonthly.com</a><br />
		Currently <a href="http://www.shipsmonthly.com/ships/home.htm" target="_blank">http://www.shipsmonthly.com/ships/home.htm</a>
	</li>
<li>
		<a href="http://beta.yachtingmonthly.com" target="_blank">http://beta.yachtingmonthly.com</a><br />
		Currently <a href="http://www.yachtingmonthly.com/ym/home.htm" target="_blank">http://www.yachtingmonthly.com/ym/home.htm</a>
	</li>
<li>
		<a href="http://beta.yachtingworld.com" target="_blank">http://beta.yachtingworld.com</a><br />
		Currently <a href="http://www.yachtingworld.com/yw/home.htm" target="_blank">http://www.yachtingworld.com/yw/home.htm</a>
	</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/06/08/2009/introducing-some-new-beta-sites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Szohatzky Heads for Hungary</title>
		<link>http://www.inspirelabs.co.uk/05/07/2009/szohatzky-heads-for-hungary/</link>
		<comments>http://www.inspirelabs.co.uk/05/07/2009/szohatzky-heads-for-hungary/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 10:30:24 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Team News]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=117</guid>
		<description><![CDATA[After bidding farewell to Fabien just a few weeks ago, it&#8217;s once again time to say our goodbyes &#8211; this time to Daniel, after 2½ years of moaning about our food service. Daniel has decided to jump ship and head back to his native, Eastern Bloc state of Hungary where he will pursue an education [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_118" class="wp-caption alignright" style="width: 260px"><img class="size-full wp-image-118" title="Daniel" src="http://inspirelabs.co.uk/wp-content/uploads/2009/07/4182_99339331321_556271321_2555336_4738671_n.jpg" alt="Daniel" width="250" height="150" /><p class="wp-caption-text">Daniel</p></div>
<p>After bidding farewell to Fabien just a few weeks ago, it&#8217;s once again time to say our goodbyes &#8211; this time to Daniel, after 2½ years of <span style="text-decoration: line-through;">moaning about our food</span> service.</p>
<p>Daniel has decided to jump ship and head back to his native, <a href="http://upload.wikimedia.org/wikipedia/commons/0/03/Concrete-block,japan.JPG" target="_blank">Eastern Bloc</a> state of Hungary where he will pursue an education in a new walk of life.</p>
<p>During his time in England, Daniel has demonstrated that the eastern-European population has a lot to offer: they can name more than 5 European countries, they know the names of more capital cities than we know counties of our own country and, more importantly, the population consists of many <a href="http://img5.travelblog.org/Photos/23164/332033/f/3105098-Hungarian-woman-0.jpg" target="_blank">hot</a> <a href="http://static.szanalmas.hu/postpix/62268_2.jpg" target="_blank">women</a>.</p>
<p>Daniel will be missed by all. Fortunately, though, there will at least be more sugar and salt available to the British population and the office can finally rid itself of that rancid <a href="http://en.wikipedia.org/wiki/Unicum" target="_blank">Unicum</a>.</p>
<p>Much love, Mr Szohatzky. Good luck, and see you again soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/05/07/2009/szohatzky-heads-for-hungary/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Karl Bares Chest</title>
		<link>http://www.inspirelabs.co.uk/26/05/2009/karl-bares-chest/</link>
		<comments>http://www.inspirelabs.co.uk/26/05/2009/karl-bares-chest/#comments</comments>
		<pubDate>Tue, 26 May 2009 18:20:09 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Team News]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=103</guid>
		<description><![CDATA[Upon arriving at work today in a vest that Rambo would be proud of, Karl was quick to receive all forms of feedback on his chosen atire. Although covered with matching shirt, we knew his intentions were to rip out the guns. Back in February, we chose male cancer charity Orchid as our first Charity [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_104" class="wp-caption alignright" style="width: 235px"><img class="size-medium wp-image-104" title="All that is man" src="http://inspirelabs.co.uk/wp-content/uploads/2009/05/vest-225x300.jpg" alt="All that is man" width="225" height="300" /><p class="wp-caption-text">All that is man</p></div>
<p>Upon arriving at work today in a vest that Rambo would be proud of, Karl was quick to receive all forms of feedback on his chosen atire. Although covered with matching shirt, we knew his intentions were to rip out the guns.</p>
<p>Back in February, we chose male cancer charity <a href="http://www.orchid-cancer.org.uk/" target="_blank">Orchid</a> as our first Charity of the Year. We took this opportunity to not only allow Karl to fulfil his desire to bare his chest, but also raise some money for Orchid. Within a single hour, we raised a whopping £80 and spent the rest of the day marvelling at Karl&#8217;s <em>all-that-is-man</em> hunkiness.</p>
<p>Earlier in the year, a drunken (yet innovative) selection of the Inspire team took it upon themselves to drop trousers and run around the pub and surrounding obstacles for all to admire. Injuries were attained including a broken belt, ripped jeans and damaged egos, though we did manage to raise an unprecidented £64 in just 30 minutes.</p>
<p>That brings the sum total to £144 earned in just two seperate and unorganised occasions. We endeavour to continue our spontaneous sponsorship ordeals, but we need your ideas. Share them&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/26/05/2009/karl-bares-chest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Au Revoir, Fabien!</title>
		<link>http://www.inspirelabs.co.uk/05/05/2009/au-revoir-fabien/</link>
		<comments>http://www.inspirelabs.co.uk/05/05/2009/au-revoir-fabien/#comments</comments>
		<pubDate>Tue, 05 May 2009 14:55:01 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Team News]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=50</guid>
		<description><![CDATA[Last Wednesday we said goodbye our best member-of-the-team-who-is-french, monsieur Fabien Grenier. Booo! Fabien has been a part of the team for over two years and, foolishly, he believes someone can offer him more love than that of Team Inspire. This summer, he will be will be heading back to the homeland to get himself married. Even [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_51" class="wp-caption alignright" style="width: 260px"><img class="size-full wp-image-51" title="Fabien" src="http://inspirelabs.co.uk/wp-content/uploads/2009/05/fabien.jpg" alt="Bring out the gimp" width="250" height="300" /><p class="wp-caption-text">Bring out the gimp</p></div>
<p>Last Wednesday we said goodbye our best member-of-the-team-who-is-french, monsieur Fabien Grenier. Booo!</p>
<p>Fabien has been a part of the team for over two years and, foolishly, he believes someone can offer him more love than that of Team Inspire. This summer, he will be will be heading back to the homeland to get himself married. Even more heartbreaking, Grenier has decided to depart us for good and begin his own venture back in Paris.</p>
<p>Have a trés bien wedding and we hope your entrepreneurship is a success!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/05/05/2009/au-revoir-fabien/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Switching EOL Styles</title>
		<link>http://www.inspirelabs.co.uk/04/05/2009/switching-eol-styles/</link>
		<comments>http://www.inspirelabs.co.uk/04/05/2009/switching-eol-styles/#comments</comments>
		<pubDate>Mon, 04 May 2009 19:47:33 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=48</guid>
		<description><![CDATA[There are many things in programming that can p*ss you off. Simple things like line endings in the wrong (or mixed) format are even more irritating. For some unknown reason, occasionally my PHP IDE decides, by itself, to start converting my unix line endings to Windows ones. Yes, I do have the correct configuration setup. [...]]]></description>
			<content:encoded><![CDATA[<p>There are many things in programming that can p*ss you off. Simple things like line endings in the wrong (or mixed) format are even more irritating.</p>
<p>For some unknown reason, occasionally my PHP IDE decides, by itself, to start converting my unix line endings to Windows ones. Yes, I do have the correct configuration setup. So, while this bug in the IDE exists, I like to run a quick command in my Ubuntu shell before commiting the code back into the repository.</p>
<p>First, you need a little app called <a href="http://ccrma.stanford.edu/~craig/utility/flip/" target="_blank">flip</a> (available for multiple platforms but I&#8217;ll focus on Ubuntu).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> flip</pre></div></div>

<p>Next, head to your project root folder and run the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;\.svn&quot;</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> flip <span style="color: #660033;">-vu</span> <span style="color: #007800;">$i</span>; <span style="color: #000000; font-weight: bold;">done</span>;</pre></div></div>

<p>This will first find all non-Subversion files then <em>flip</em> them to Unix-format line endings. And don&#8217;t worry about binary files, these will be untouched unless you explicitly tell flip to convert these using the <code>-b</code> option.</p>
<p>On Solaris and other linux flavours, you will probably have access to <code>dos2unix</code> which does the same thing. The syntax is a little different:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dos2unix <span style="color: #000000; font-weight: bold;">&lt;</span>filename<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>filename<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>That&#8217;s not a typo, specify the filename twice otherwise you&#8217;ll get the updated content spewed out at you in STDOUT.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/04/05/2009/switching-eol-styles/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Changing the PHP Session Lifetime</title>
		<link>http://www.inspirelabs.co.uk/04/05/2009/changing-the-php-session-lifetime/</link>
		<comments>http://www.inspirelabs.co.uk/04/05/2009/changing-the-php-session-lifetime/#comments</comments>
		<pubDate>Mon, 04 May 2009 19:32:52 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://inspirelabs.co.uk/?p=40</guid>
		<description><![CDATA[As anyone who has attempted to use the default PHP session handler has probably noticed, sessions naturally die after a period of inactivity. What you&#8217;ll probably want in most situations is for the session not to die (or &#8216;expire&#8217;) until the user closes their browser. Unfortunately, there is no server-side way of knowing for certain [...]]]></description>
			<content:encoded><![CDATA[<p>As anyone who has attempted to use the default PHP session handler has probably noticed, sessions naturally die after a period of inactivity.</p>
<p>What you&#8217;ll probably want in most situations is for the session not to die (or &#8216;expire&#8217;) until the user closes their browser. Unfortunately, there is no server-side way of knowing <strong>for certain</strong> when the browser is closed and can only assume it has been closed after a period of inactivity (user hasn&#8217;t made any requests).</p>
<p>First, let&#8217;s take a brief look at how the default PHP session handler works&#8230;</p>
<p>Before a session can be used, the <a href="http://php.net/session_start" target="_blank"><code>session_start()</code></a> function must be called. This function will perform the necessary steps to initialise a new session and read in any data from an existing one. In addition, this method also does some tidying up which ultimately kills your sessions prematurely.</p>
<p>To keep session data tidy on your server, PHP will perform some &#8216;garbage collection&#8217; (GC) &#8212; that is, PHP will search for any session data that it thinks is old then deletes it. The default session handler uses a <code>session.gc_maxlifetime</code> configuration option which allows the application to set the lifetime of its session. This value is in seconds and defaults to 1440 (24 minutes). Therefore, any sessions that have been inactive for more than 24 minutes will be considered dead. This is not very helpful in Content Management Systems where it can take longer for the user to write their copy, only to be logged out when they come to submit the content.</p>
<p>One other little quirk that PHP likes to throw at you is the issue that arises when attempting to store session data with varying lifetimes in the same directory. What the default handler will do in this case is get the shortest lifetime and apply it to all sessions in the same folder. For example, let&#8217;s say you have Project A which used a session lifetime of 1440 and Project B which used 2400, both storing their session data in <code>/tmp/sessions</code>. It&#8221;ll save you a headache to know that Project B sessions will die after 1440 seconds. There are two obvious solutions for this: 1) create a subfolder for each project (e.g. <code>/tmp/sessions/myproject</code>; or 2) create a subfolder for each lifetime (e.g. <code>/tmp/sessions/1440</code>).</p>
<p>As a sidenote &#8212; to minimise the load that GC process puts on the server, PHP will not perform a GC every time the <code>session_start()</code> is called. Instead, the directives <code>session.gc_probability</code> and <code>session.gc_divisor</code> can be set. For example, 1 and 100, respectively, means that there is a 1-in-100 (1%) chance that PHP will perform a GC when a session is started (more information available in the <a href="http://php.net/manual/en/session.configuration.php" target="_blank">PHP manual</a>).</p>
<p>So, how do we change the default lifetime of 24 minutes? There are two solutions:</p>
<ol>
<li>Play around with a few PHP settings, either in the php.ini file or at runtime using <a href="http://php.net/ini_set" target="_blank"><code>ini_set()</code></a>, so that they have a longer lifetime</li>
<li>Create a custom session handler with a more complex GC strategy</li>
</ol>
<p>In most instances you&#8217;ll probably go for the first option as it is relatively simple and probably faster than most custom solutions. So, to get you started, here is a snippet of code which will create a 24-hour session (you could class this as an &#8216;infinite&#8217; session for most typical cases).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Choose your desired lifetime</span>
<span style="color: #000088;">$lifetime</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">86400</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 24 hours</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Consider sessions dead after 24 hours</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session.gc_maxlifetime'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lifetime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Store the sessions in a subdirectory based on the lifetime</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session.save_path'</span><span style="color: #339933;">,</span> <span style="color: #990000;">ini_get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session.save_path'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$lifetime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Now start the session as usual</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Let us know how you get on!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/04/05/2009/changing-the-php-session-lifetime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Inspire Labs</title>
		<link>http://www.inspirelabs.co.uk/16/04/2009/introducing-inspire-labs/</link>
		<comments>http://www.inspirelabs.co.uk/16/04/2009/introducing-inspire-labs/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 13:04:00 +0000</pubDate>
		<dc:creator>Adam Pancutt</dc:creator>
				<category><![CDATA[Uncategorised]]></category>

		<guid isPermaLink="false">http://blog.inspirelabs.co.uk/?p=3</guid>
		<description><![CDATA[Yay &#8211; the first post! Want to know what this blog will be all about? Check out the About page.]]></description>
			<content:encoded><![CDATA[<p>Yay &#8211; the first post! Want to know what this blog will be all about? Check out the <a href="/about/">About</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.inspirelabs.co.uk/16/04/2009/introducing-inspire-labs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

