<?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: Secure Jquery Ajax Request</title>
	<atom:link href="http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/</link>
	<description>PHP Freelance Developer</description>
	<lastBuildDate>Thu, 03 Jun 2010 20:58:51 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Prasanna</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-121</link>
		<dc:creator>Prasanna</dc:creator>
		<pubDate>Thu, 18 Feb 2010 12:21:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-121</guid>
		<description>@Sym2k8
die(‘Direct acces not allowed’); is much better perhaps?</description>
		<content:encoded><![CDATA[<p>@Sym2k8<br />
die(‘Direct acces not allowed’); is much better perhaps?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sym2k8</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-114</link>
		<dc:creator>Sym2k8</dc:creator>
		<pubDate>Thu, 21 Jan 2010 19:35:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-114</guid>
		<description>Thanks, but the problem is that you still send the data to the client.

The better way is to not send data to the client if the client is not authorized.

Do never trust the client and do never trust code and checks wich can be manipulated by the client (javascript).

My function secure would look like:
public function secure() {
    if(IS_AJAX) {
	    if(!$this-&gt;session-&gt;userdata(&#039;logged_in&#039;)) {
		    header(&#039;HTTP/1.1 401 Unauthorized&#039;);
			die;
		}
		echo &#039;Time for Coffee&#039;;		
	} else {
	    echo &#039;Direct acces not allowed&#039;;
	}
}

Greetings from germany,
Sym2k8</description>
		<content:encoded><![CDATA[<p>Thanks, but the problem is that you still send the data to the client.</p>
<p>The better way is to not send data to the client if the client is not authorized.</p>
<p>Do never trust the client and do never trust code and checks wich can be manipulated by the client (javascript).</p>
<p>My function secure would look like:<br />
public function secure() {<br />
    if(IS_AJAX) {<br />
	    if(!$this-&gt;session-&gt;userdata(&#8217;logged_in&#8217;)) {<br />
		    header(&#8217;HTTP/1.1 401 Unauthorized&#8217;);<br />
			die;<br />
		}<br />
		echo &#8216;Time for Coffee&#8217;;<br />
	} else {<br />
	    echo &#8216;Direct acces not allowed&#8217;;<br />
	}<br />
}</p>
<p>Greetings from germany,<br />
Sym2k8</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shin</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-105</link>
		<dc:creator>shin</dc:creator>
		<pubDate>Sun, 13 Dec 2009 21:14:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-105</guid>
		<description>Yes, I agree with all other posts. I am looking forward to seeing the next ones. 
@Alex, CI backendpro is the one you are looking for.
@Bill Thanks for your tip.</description>
		<content:encoded><![CDATA[<p>Yes, I agree with all other posts. I am looking forward to seeing the next ones.<br />
@Alex, CI backendpro is the one you are looking for.<br />
@Bill Thanks for your tip.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Natan V</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-102</link>
		<dc:creator>Natan V</dc:creator>
		<pubDate>Sat, 12 Dec 2009 01:15:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-102</guid>
		<description>Great Idea!

You can also add the event to the jquery ajax global settings.  This way you don&#039;t have to attach the event to every ajax request (if you&#039;re using some sort of ACL).  

I added the following to my header for auto inclusion.

jQuery.ajaxSetup({
	error: function(xhr, requestStatus, error)
	{
	    if(xhr.status == 401)
	    {
		// redirect here or do whatever...
	    }
	}
	,cache: false
    });</description>
		<content:encoded><![CDATA[<p>Great Idea!</p>
<p>You can also add the event to the jquery ajax global settings.  This way you don&#8217;t have to attach the event to every ajax request (if you&#8217;re using some sort of ACL).  </p>
<p>I added the following to my header for auto inclusion.</p>
<p>jQuery.ajaxSetup({<br />
	error: function(xhr, requestStatus, error)<br />
	{<br />
	    if(xhr.status == 401)<br />
	    {<br />
		// redirect here or do whatever&#8230;<br />
	    }<br />
	}<br />
	,cache: false<br />
    });</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Walter</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-100</link>
		<dc:creator>Walter</dc:creator>
		<pubDate>Thu, 26 Nov 2009 07:50:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-100</guid>
		<description>Great screencast. I&#039;ll be tuned for more!!</description>
		<content:encoded><![CDATA[<p>Great screencast. I&#8217;ll be tuned for more!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-96</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Fri, 13 Nov 2009 15:17:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-96</guid>
		<description>Thank you so much for your tutorials, they are some of the best I&#039;ve seen in way of the intersection of CI+jQuery+ajax...</description>
		<content:encoded><![CDATA[<p>Thank you so much for your tutorials, they are some of the best I&#8217;ve seen in way of the intersection of CI+jQuery+ajax&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: August</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-90</link>
		<dc:creator>August</dc:creator>
		<pubDate>Tue, 27 Oct 2009 16:13:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-90</guid>
		<description>Hi, i am trying to make a login page that requires a local key (user-side) as well as the username and password.  

the idea is to hash the user info against the users key, and use the public key to decrypt and authorize. 

if i get it working i will toss you a link</description>
		<content:encoded><![CDATA[<p>Hi, i am trying to make a login page that requires a local key (user-side) as well as the username and password.  </p>
<p>the idea is to hash the user info against the users key, and use the public key to decrypt and authorize. </p>
<p>if i get it working i will toss you a link</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toby</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-87</link>
		<dc:creator>Toby</dc:creator>
		<pubDate>Sat, 03 Oct 2009 16:03:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-87</guid>
		<description>Lee, thanks for your great screencasts, they are really helpful!

Like Alex Inoa, I am also very interessted in UAC with CI! Would be great to see something about this soon :)

Regards, Toby</description>
		<content:encoded><![CDATA[<p>Lee, thanks for your great screencasts, they are really helpful!</p>
<p>Like Alex Inoa, I am also very interessted in UAC with CI! Would be great to see something about this soon <img src='http://www.weblee.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Regards, Toby</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bill h</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-59</link>
		<dc:creator>bill h</dc:creator>
		<pubDate>Fri, 14 Aug 2009 22:52:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-59</guid>
		<description>I am not sure if you have fixed the cacheing issues you were having in firefox but what you can do is download the web developer toolbar for firefox (https://addons.mozilla.org/en-US/firefox/addon/60) and then under the first menu item &quot;disable&quot; just select &quot;disable cache&quot;. 

I do this while I am developing to avoid the exact same issues you were having.</description>
		<content:encoded><![CDATA[<p>I am not sure if you have fixed the cacheing issues you were having in firefox but what you can do is download the web developer toolbar for firefox (<a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow">https://addons.mozilla.org/en-US/firefox/addon/60</a>) and then under the first menu item &#8220;disable&#8221; just select &#8220;disable cache&#8221;. </p>
<p>I do this while I am developing to avoid the exact same issues you were having.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.weblee.co.uk/2009/06/25/secure-jquery-ajax-request/comment-page-1/#comment-58</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Fri, 14 Aug 2009 22:46:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.weblee.co.uk/?p=264#comment-58</guid>
		<description>Hi Mike

Thank you for asking. Yea I will be doing more just a little busy with a project right now.

Keep watching :-)</description>
		<content:encoded><![CDATA[<p>Hi Mike</p>
<p>Thank you for asking. Yea I will be doing more just a little busy with a project right now.</p>
<p>Keep watching <img src='http://www.weblee.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
