Is it possible getting cookie from an external js with Php before generating HTML to the browser?
Something like
<?
//Get if i have some cookie information
if($_COOKIE["js_app"])
$cookie_js = $_COOKIE["js_app"];
//now, talk with some app.js
if($cookie_js)
$cookie = some_function(target = 'some_domanin/app.js',$cookie_js);
else
$cookie = some_function(target = 'some_domanin/app.js');
$_COOKIE["js_app"] = $cookie;
//now i can generate the HTML output.
....
?>
It isn’t possible because the javascript would never be executed. Your
some_function(assuming it used cURL to make the request and pass along the cookie), would just receive the javascript code (like what happens when you view javascript source in your browser).When JS is loaded by the browser, the browser’s javascript interpreter handles parsing and executing the javascript.
Edit: Hmm… googling for “php javascript interpreter” resulted in http://j4p5.sourceforge.net/index.php. Never used it before and probably never will but if you don’t need to interact with the user-side of things, that might help you out.