<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Store login information in cookie using jQuery</title>
	<atom:link href="http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/</link>
	<description>Web Development, Web Design, Web Applications, Web 2.0, AJAX, WordPress Themes, Search Engine Optimisation, Latest Technologies and more..</description>
	<lastBuildDate>Tue, 20 Mar 2012 09:48:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Will</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-100629</link>
		<dc:creator>Will</dc:creator>
		<pubDate>Sun, 30 Aug 2009 16:50:43 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-100629</guid>
		<description>Just wanted to say that I agree with the argument that storing usernames and passwords in cookies is not good practice, even if they are encrypted with something like md5.

If you&#039;re using php a better way to authenticate would be to use sessions and have the server set a variable in the $_SESSION array. You might also want to set a initial login timestamp value in that array, as well as a &quot;last action&quot; timestamp, and write your security rules based on these.

Another way of doing security in an *AMP environment is to store that data in a database table (currently logged in users) and use the session key (which is stored in a cookie or can be appended to the url if cookies are off). This is the method that expression engine uses and is quite secure.

You can then set up your rules on the server side so users are prompted for passwords more or less frequently, according to the level of security you need.</description>
		<content:encoded><![CDATA[<p>Just wanted to say that I agree with the argument that storing usernames and passwords in cookies is not good practice, even if they are encrypted with something like md5.</p>
<p>If you&#8217;re using php a better way to authenticate would be to use sessions and have the server set a variable in the $_SESSION array. You might also want to set a initial login timestamp value in that array, as well as a &#8220;last action&#8221; timestamp, and write your security rules based on these.</p>
<p>Another way of doing security in an *AMP environment is to store that data in a database table (currently logged in users) and use the session key (which is stored in a cookie or can be appended to the url if cookies are off). This is the method that expression engine uses and is quite secure.</p>
<p>You can then set up your rules on the server side so users are prompted for passwords more or less frequently, according to the level of security you need.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Baker</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-93153</link>
		<dc:creator>Ben Baker</dc:creator>
		<pubDate>Thu, 16 Jul 2009 12:01:10 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-93153</guid>
		<description>Hey,

Been looking into this a bit more.

There&#039;s a jQuery MD5 script here: www.semnanweb.com/jquery-plugin/md5.html

I think storing the encrypted MD5 password in the cookie then matching that to the password in the db via an MD5 comparison.

So as an example jQuery to PHP query:

jQuery:
// get user name and passwrord values
var user = $(&quot;#user_name&quot;).val();
var pwd = trim( $(&quot;#user_pwd&quot;).val() );

// make ajax call with data	
	$.ajax({
		type: &quot;POST&quot;,
		url: &quot;login.php&quot;,
		data: &#039;user=&#039;+ user + &#039;&amp;pwd=&#039; + $.md5( pwd ),
		success: loginResponse
     });

php:

// get password from post vars
$pwd = mysql_real_escape_string( $_POST[&#039;pwd&#039;] );

// query string - using sql md5()
$query = &quot;SELECT `user_password` FROM `tbl_users `WHERE MD5( `user_password` ) = &#039;&quot;.pwd.&quot;&#039;&quot; ;

// now run query...

On a successful match you can then store you cookie data, storing the password as md5.

I think this is a good way to do it. :)</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>Been looking into this a bit more.</p>
<p>There&#8217;s a jQuery MD5 script here: <a href="http://www.semnanweb.com/jquery-plugin/md5.html" rel="nofollow">http://www.semnanweb.com/jquery-plugin/md5.html</a></p>
<p>I think storing the encrypted MD5 password in the cookie then matching that to the password in the db via an MD5 comparison.</p>
<p>So as an example jQuery to PHP query:</p>
<p>jQuery:<br />
// get user name and passwrord values<br />
var user = $(&#8220;#user_name&#8221;).val();<br />
var pwd = trim( $(&#8220;#user_pwd&#8221;).val() );</p>
<p>// make ajax call with data<br />
	$.ajax({<br />
		type: &#8220;POST&#8221;,<br />
		url: &#8220;login.php&#8221;,<br />
		data: &#8216;user=&#8217;+ user + &#8216;&amp;pwd=&#8217; + $.md5( pwd ),<br />
		success: loginResponse<br />
     });</p>
<p>php:</p>
<p>// get password from post vars<br />
$pwd = mysql_real_escape_string( $_POST['pwd'] );</p>
<p>// query string &#8211; using sql md5()<br />
$query = &#8220;SELECT `user_password` FROM `tbl_users `WHERE MD5( `user_password` ) = &#8216;&#8221;.pwd.&#8221;&#8216;&#8221; ;</p>
<p>// now run query&#8230;</p>
<p>On a successful match you can then store you cookie data, storing the password as md5.</p>
<p>I think this is a good way to do it. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eisabai</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-93047</link>
		<dc:creator>eisabai</dc:creator>
		<pubDate>Wed, 15 Jul 2009 01:45:39 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-93047</guid>
		<description>Hi Ben,
I agree it&#039;s a good practice to encrypt cookies that contain sensitive information like username and password.  Thank you for the link.  :)</description>
		<content:encoded><![CDATA[<p>Hi Ben,<br />
I agree it&#8217;s a good practice to encrypt cookies that contain sensitive information like username and password.  Thank you for the link.  :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Baker</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-93020</link>
		<dc:creator>Ben Baker</dc:creator>
		<pubDate>Tue, 14 Jul 2009 13:54:49 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-93020</guid>
		<description>Hey eisabai,

That&#039;s good to know regarding secure transmit of data, but as far as I understand it the cookie is stored locally, on the users machine, right?

So you are storing the users password unencrypted in a cookie, which can be accessed and viewed.

I was thinking more along the lines of MD5 cryptography for the password/string? see here: http://pajhome.org.uk/crypt/md5/

B ;)</description>
		<content:encoded><![CDATA[<p>Hey eisabai,</p>
<p>That&#8217;s good to know regarding secure transmit of data, but as far as I understand it the cookie is stored locally, on the users machine, right?</p>
<p>So you are storing the users password unencrypted in a cookie, which can be accessed and viewed.</p>
<p>I was thinking more along the lines of MD5 cryptography for the password/string? see here: <a href="http://pajhome.org.uk/crypt/md5/" rel="nofollow">http://pajhome.org.uk/crypt/md5/</a></p>
<p>B ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eisabai</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-89700</link>
		<dc:creator>eisabai</dc:creator>
		<pubDate>Tue, 09 Jun 2009 02:35:15 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-89700</guid>
		<description>Hi Ben,

You can set the secure flag for the cookies so they are only transmitted via secured connections (SSL).  

For example:

$.cookie(&#039;username&#039;, username, { expires: 14, secure: true });</description>
		<content:encoded><![CDATA[<p>Hi Ben,</p>
<p>You can set the secure flag for the cookies so they are only transmitted via secured connections (SSL).  </p>
<p>For example:</p>
<p>$.cookie(&#8216;username&#8217;, username, { expires: 14, secure: true });</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Baker</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-89667</link>
		<dc:creator>Ben Baker</dc:creator>
		<pubDate>Mon, 08 Jun 2009 19:37:27 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-89667</guid>
		<description>Hey, thanks for the code!

Works a charm. Although isn&#039;t it a bad idea to store the users password unprotected in a cookie?

Is there any encryption that can be applied?

B ;)</description>
		<content:encoded><![CDATA[<p>Hey, thanks for the code!</p>
<p>Works a charm. Although isn&#8217;t it a bad idea to store the users password unprotected in a cookie?</p>
<p>Is there any encryption that can be applied?</p>
<p>B ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin Sawant</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-87785</link>
		<dc:creator>Nitin Sawant</dc:creator>
		<pubDate>Mon, 18 May 2009 07:44:16 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-87785</guid>
		<description>thanks a lot, it really helped me</description>
		<content:encoded><![CDATA[<p>thanks a lot, it really helped me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeottelak</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-81838</link>
		<dc:creator>Jeottelak</dc:creator>
		<pubDate>Tue, 07 Apr 2009 18:14:07 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-81838</guid>
		<description>mm... bookmarked )</description>
		<content:encoded><![CDATA[<p>mm&#8230; bookmarked )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Chapman</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-81688</link>
		<dc:creator>Ben Chapman</dc:creator>
		<pubDate>Tue, 07 Apr 2009 01:52:59 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-81688</guid>
		<description>Terrific!

Thanks for this.</description>
		<content:encoded><![CDATA[<p>Terrific!</p>
<p>Thanks for this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eisabai</title>
		<link>http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/comment-page-1/#comment-80099</link>
		<dc:creator>eisabai</dc:creator>
		<pubDate>Sat, 28 Mar 2009 10:10:04 +0000</pubDate>
		<guid isPermaLink="false">http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/#comment-80099</guid>
		<description>No prob!  Glad you got it sorted out.</description>
		<content:encoded><![CDATA[<p>No prob!  Glad you got it sorted out.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

