<?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>Francois Faubert &#187; Security</title>
	<atom:link href="http://www.francoisfaubert.com/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.francoisfaubert.com</link>
	<description></description>
	<lastBuildDate>Tue, 08 Sep 2009 19:00:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Amazon&#8217;s security mesures</title>
		<link>http://www.francoisfaubert.com/2008/07/08/amazons-security-mesures/</link>
		<comments>http://www.francoisfaubert.com/2008/07/08/amazons-security-mesures/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 14:22:32 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[E-Commerce]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.francoisfaubert.com/?p=75</guid>
		<description><![CDATA[It&#8217;s really important to know which websites to trust when you make transactions online. It&#8217;s even more critical to know you can&#8217;t fully trust anybody.
You do have to let it go at some point though: just like one chooses to trust your Mom &#038; Pop&#8217;s local merchants won&#8217;t duplicate your credit card while scanning them [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s really important to know which websites to trust when you make transactions online. It&#8217;s even more critical to know you can&#8217;t fully trust anybody.</p>
<p>You do have to let it go at some point though: just like one chooses to trust your Mom &#038; Pop&#8217;s local merchants won&#8217;t duplicate your credit card while scanning them under the counter, you have to expect websites to treat your private information respectfully.</p>
<p>Amazon just sent me an alert saying another user tried to make purchases with my credit card, which they had previously linked with my account over there. I didn&#8217;t expect them to actually make proactive checks like these and was pleasantly surprised.</p>
<p>I have yet to understand when my card information was harvested and if transactions were made on other websites, but at least Amazon&#8217;s suspicion will be noticed by my credit card provider.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2008/07/08/amazons-security-mesures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving PHP Sessions to MySQL</title>
		<link>http://www.francoisfaubert.com/2007/06/16/saving-php-sessions-to-mysql/</link>
		<comments>http://www.francoisfaubert.com/2007/06/16/saving-php-sessions-to-mysql/#comments</comments>
		<pubDate>Sat, 16 Jun 2007 20:23:24 +0000</pubDate>
		<dc:creator>francoisfaubert</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[The Music Tank]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Sessions]]></category>

		<guid isPermaLink="false">http://fake.themusictank.com/2007/06/16/saving-php-sessions-to-mysql/</guid>
		<description><![CDATA[In most cases, websites don&#8217;t necessarily need to be managed by sessions that end as soon as the users closes their browser. Most websites now offer to keep their session alive for whatever amount of time. This is really less of a hassle for your users and adds to the positive user experience.
Learning what not [...]]]></description>
			<content:encoded><![CDATA[<p>In most cases, websites don&#8217;t necessarily need to be managed by sessions that end as soon as the users closes their browser. Most websites now offer to keep their session alive for whatever amount of time. This is really less of a hassle for your users and adds to the positive user experience.</p>
<p><strong>Learning what not to do </strong></p>
<p>On TMT, I used to handle sessions manually by storing the encrypted value of the user&#8217;s id in a cookie. That&#8217;s is highly unrecommended for security reasons as its fairly easy to hack your way around using an id that isn&#8217;t yours (and which might be the administrator&#8217;s!). </p>
<p>I experimented by storing so-called &#8216;unique&#8217; values I generated and stored in MySQL to have better validation when decrypting the cookie, but since you can spoof most $_SERVER values (which provides the user&#8217;s IP), it really wasn&#8217;t good enough.</p>
<p><strong>Hardcore PHP-ing</strong></p>
<p>You can override the whole session object using PHP&#8217;s <code><a href="http://www.php.net/manual/en/function.session-set-save-handler.php">session_set_save_handler()</a></code> function. Basically, you re-program what the object does when it reads and writes session values or when it destroys itself.</p>
<p>Instead of writing the session values to a file on the server like the default behavior is set to do, you can redirect the data handling to an insert or update query in your favorite database.</p>
<p><strong>Advantages</strong></p>
<p>The most obvious advantage is that you can keep the sessions alive as long as your server is live, more or less. You can also change the condition of how session expiration are done. For instance, through a simple MySQL query, TMT sessions can be kept for one week before being destroyed if no activity is logged.</p>
<p>I&#8217;ve read it&#8217;s safer to store session values that way too, as a possible hacker would need the database&#8217;s password to access it. While I&#8217;m not sure how harder this method actually makes it for hackers in reality, I really feel safer to use PHP&#8217;s native object rather than a shaky class I would have written.</p>
<p>Fully using PHP&#8217;s native session object allows more flexibility as you are very close to Apache. You can therefore validate with confidence (not blind confidence though) that the user is indeed human and not a spam bot, save the user&#8217;s preferred language or do whatever else your website offers as possible features without fear. In my previous horrible system, it wasn&#8217;t even a possibility.</p>
<p><strong>Examples</strong></p>
<p>Apart from <em>stalker at ruun dot de</em>&#8217;s very good comment on PHP.net&#8217;s documentation page, I found <a href="http://www.tonymarston.net/php-mysql/session-handler.html">Tony Marston</a>&#8217;s version of the object. The latter is harder to grasp as he uses his own object-oriented system to get database data &#8212; that&#8217;s good practice, but a bit harder to learn from. You can also see TMT&#8217;s class in our <a href="http://themusictank.svn.sourceforge.net/viewvc/themusictank/trunk/brain/php_Session.php?revision=22&amp;view=markup">SVN repository</a>.</p>
<p>The important thing is just to understand what you&#8217;re trying to do rather than copy pasting each of our codes. TMT&#8217;s only started working once I grasped the concept.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.francoisfaubert.com/2007/06/16/saving-php-sessions-to-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
