<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-31781999</atom:id><lastBuildDate>Sun, 01 Mar 2009 07:00:43 +0000</lastBuildDate><title>Mr Bubu</title><description>Information about computers and their surroundings, by a programmer for programmers.</description><link>http://mrbubu.blogspot.com/</link><managingEditor>noreply@blogger.com (Bruno Cassol)</managingEditor><generator>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-31781999.post-115513603325708313</guid><pubDate>Wed, 09 Aug 2006 14:31:00 +0000</pubDate><atom:updated>2006-08-09T10:08:00.166-07:00</atom:updated><title>PHP Session Lifetime: A work around session.gc_maxlifetime</title><description>&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger/8100/3462/200/php.jpg" alt="" border="0" /&gt;I needed to limit my session life time in a specific site running in my remote server. But could not set session.gc_maxlifetime. Also I know that &lt;a href="http://blog.centresource.com/2006/05/23/php-session-lifetime-an-adventure/"&gt;session.gc_maxlifetime is not good&lt;/a&gt;! It is not reliable and it's tricky to get a different session max life time for each site running in your server.&lt;br /&gt;&lt;br /&gt;So I made my own script that would clean session and cookies after a predefined number of minutes. Then all I had to do is to include this script in the start of my index.php:&lt;br /&gt;&lt;br /&gt;&lt;img style="cursor: pointer;" src="http://photos1.blogger.com/blogger/8100/3462/320/php_open_tag.jpg" alt="" border="0" /&gt;&lt;br /&gt;&lt;pre class="code"&gt;// checks if session is idle for too much time&lt;br /&gt;// if it is it will erase all session vars!&lt;br /&gt;// if not it will update last activity time&lt;br /&gt;// returns true if session was wiped&lt;br /&gt;function session_check() {&lt;br /&gt; // time out in seconds&lt;br /&gt; $max_idle_time = 10 * 60;&lt;br /&gt; // name of session variable used to store last activity&lt;br /&gt; $sname = '_session_last_activity';&lt;br /&gt; $cleaned = false;&lt;br /&gt;&lt;br /&gt; // start session if it wasn't yet&lt;br /&gt; if (session_id() == '') session_start();&lt;br /&gt;&lt;br /&gt; // check if session variable is set&lt;br /&gt; if (isset($_SESSION[$sname])) {&lt;br /&gt;  $t_old = $_SESSION[$sname];&lt;br /&gt;  $t_now = mktime();&lt;br /&gt;  // check if session expired&lt;br /&gt;  if ($t_now - $t_old &amp;gt; $max_idle_time) {&lt;br /&gt;   // wipe sessions&lt;br /&gt;   session_unset();&lt;br /&gt;   session_destroy();&lt;br /&gt;   $_SESSION = array();&lt;br /&gt;   // wipe cookies&lt;br /&gt;   foreach ($_COOKIE as $key =&amp;gt; $value) setcookie($key, '',&lt;br /&gt;   time()-1);&lt;br /&gt;   $cleaned = true;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; // create or refresh session&lt;br /&gt; $_SESSION[$sname] = mktime();&lt;br /&gt;&lt;br /&gt; return $cleaned;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// call funtion&lt;br /&gt;if (session_check()) {&lt;br /&gt; // echo 'Session was just cleaned...';&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;img style="cursor: pointer;" src="http://photos1.blogger.com/blogger/8100/3462/320/php_close_tag.jpg" alt="" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31781999-115513603325708313?l=mrbubu.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://mrbubu.blogspot.com/2006/08/php-session-lifetime-work-around.html</link><author>noreply@blogger.com (Bruno Cassol)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-31781999.post-115405226360379983</guid><pubDate>Fri, 28 Jul 2006 01:52:00 +0000</pubDate><atom:updated>2007-12-13T16:41:32.806-08:00</atom:updated><title>One thing the world must learn</title><description>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/8100/3462/1600/01-orders.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/8100/3462/320/01-orders.gif" alt="" border="0" /&gt;&lt;/a&gt;"Hackers like to work for people with high standards. But it's not enough just to be exacting. You have to insist on the right things. Which usually means that you have to be a hacker yourself. I've seen occasional articles about how to manage programmers. Really there should be two articles: one about what to do if you are yourself a programmer, and one about what to do if you're not. And the second could probably be condensed into two words: give up."&lt;br /&gt;- Article from http://www.paulgraham.com/gh.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31781999-115405226360379983?l=mrbubu.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://mrbubu.blogspot.com/2006/07/one-thing-world-must-learn.html</link><author>noreply@blogger.com (Bruno Cassol)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></item></channel></rss>