Reputation: 21
Is it possible to use Dynamic urls for Server Sent Events? for instance
var memosource = new EventSource("https://www.website.com/myPhpFile.php?u=myusername&id="+$(".memoid").val());
If not, any workarounds or suggestions will be greatly appreciated.
Upvotes: 2
Views: 1077
Reputation: 28928
Yes. In your example $_GET['u']
and $_GET['id']
will be available in the PHP script.
Cookies are also passed. But there is no POST support.
(By the way, when I saw "dynamic URL" I was guessing you meant the domain name part would be changing. For anyone coming here with that question, the answer is "yes, except for CORS, and cookies won't send". See the Wikipedia article, or google it, or see ch.9 of my book on SSE, for the extra headers your server-side event source script will need to send.)
Upvotes: 1