views:

4030

answers:

2

I'm fairly new to the AJAX methodologies (I only recently discovered jQuery a short time ago). I am interested to know if there is anyway to authenticate a user on a PHP setup; securely.

Does jQuery have any special options to allow use of HTTPS (or any other way to encrypt my ajax call)?

Yes, I could very well just post data back to the server, but that ruins the fun. Thanks in advance. :)

+7  A: 

To use Ajax over HTTPS, you have to load the originating page over HTTPS.

Same origin policy

So, in a sense, yes -- but, not on its own.

Jonathan Lonowski
"While it is not possible to directly query websites for data due to the same origin policy, the <script> tag does not honor the same-origin policy and can be used in conjunction with JSON." - from the link you provided. Are you sure?
RodgerB
Using a script tag in conjunction with JSON is JSONP. You provide a javascript callback method (as a string) in your ajax request. The server then returns the JSON response as a parameter of this callback function. http://www.west-wind.com/Weblog/posts/107136.aspx. JSONP doesn't use XmlHTTPRequest
Luke Smith
Thanks for the explanation of JSONP. Does that prove the initial poster correct?
RodgerB
What if the login box is a popup on an http page -- the home page or any part of the site. I need to make it use https for the ajax login call, but I am not able to unless the whole site is encrypted? That's ridiculous...
lhnz
A: 

Unless jQuery already does this (I use MooTools so I wouldn't know) I'd highly suggest that you link the AJAX login to the PHP session by using a $_GET variable in the query string. This way even though it's through HTTPS, you'll still know what session its tied to for an added layer of protection.

The Wicked Flea