Reputation: 1
TLDR: Can I have a script on a server to check if the current web-browser is logged in to a particular Wordpress site?
Long version: I am attempting to set up an audio player on a Wordpress website which streams from an Icecast server. The Icecast server is set up for "http" authentication, in that when it receives a request for a file, it sends a request to an external server to make the yes/no decision - with an "ok" header being sent back to the server if everything is ok, which then allows the original request from the Wordpress website.
To the end-user this is all happening on a Wordpress site secured by a user/pass, so what I really want to happen is the Wordpress site requests the file from the Icecast server, the server then sends a request back to a custom.php on the Wordpress site which then checks if the user's browser has a current logged in session in my Wordpress site. If so, then send the "ok" header back to complete the loop.
Ive got the header working, but not the bit that checks for a logged in Wordpress session. I believe this is because its "session" is originating from the (separate) server and not on the client's browser.
I'm tying myself up in knots with this!
Icecast mount point XML:
<mount-name>/stream99.aac</mount-name>
<authentication type="url">
<option name="listener_add" value="https://myserver.com/listener_joined.php"/>
<option name="username" value="user"/>
<option name="password" value="pass"/>
<option name="auth_header" value="icecast-auth-user: 1"/>
<option name="timelimit_header" value="icecast-auth-timelimit:"/>
<option name="headers" value="x-pragma,x-token"/>
<option name="header_prefix" value="ClientHeader."/>
</authentication>
</mount>
Working "listener_joined.php":
<?php
header('icecast-auth-user: 1');
?>
I've attempted lots of combinations of Wordpress' is_user_logged_in() found on here, but with none working. I believe this is because it is the Icecast server that is polling for info (ie not logged in).
Hopefully someone can help - many thanks!
Upvotes: 0
Views: 187
Reputation: 163468
Use a querystring parameter instead.
https://icecast.example.com/stream?sessionid=abcdef1234567890
This way, you don't have to worry about headers, nor cross-origin cookies.
Upvotes: 0