My task
site1.ru site provides a comment script (individually for each page) by link (suppose) http://www.site1.ru/comments.js
(inside ajax requests are executed on site1.ru/comments.php
where the address is sent from There is a request to take all the necessary comments that relate to the requested page).
The client enters to his site (on site2.ru )
<script src="http://www.site1.ru/comments.js"></script> <div id="comments"></div> (сюда вписываются все комменты, которые предоставил сервер).
it works
- Now the problem is:
Comment can only people who have been authorized on site1.ru
.
As I am on site2.ru (and the request is sent via ajax), site1.ru does not see the cookies necessary for it to verify authorization.
How can you solve a problem optimally, without pain?
PS: I googled and read a lot of sites, half talk about communication between site2-> site1, while others talk about OpenID adaptation (if I don’t have a simple solution, I'll do it).
PPS: sql authorization verification script (i.e. I need only one unfortunate cookie):
SELECT count(`id`) as `count` FROM `users` WHERE hash = $_COOKIE['cookie_hash'] LIMIT 1
ajax
on site№1
? Why it is impossible to generate content directly with the php script? In general, if a request is sent from site 2 to site 1 via php, then it is possible in this parameter to specify whether the user is authorized or not - Alexey Shimansky$_COOKIE['cookie_hash']
Is this a type of variable from site№2
? ... You didn’t understand me with Ajax ... why should I write Ajax, when you can immediately send a poll to the server and get an answer from him. example:https://api.vk.com/method/users.get?user_ids=1
. Than to pull the page, she pulls the server, the server goes to the page, and the page gives the content. Is it crazy? - Alexey Shimansky