In an ExpressionEngine template, I'm setting a PHP session variable in a javascript file like this: (Yes, EE will parse the PHP and add plug the values to the javascript)
<?php session_start(); ?>
function check_someone_else_result(data) {
waiting_list_flag = false;
<?php $_SESSION['waiting_list_flag'] = false; ?>
if(data.CanBuy=='YES'){
show_for_someone_else();
} else {
waiting_list_flag = true;
<?php $_SESSION['waiting_list_flag'] = true; ?>
$('#sm_content .oblcontent').html($('#waiting_list').html());
$('#sm_content a.closebtn').click(function(){location.reload(true);});
$('#sm_content a.yeswaitbtn').click(function(){show_for_someone_else();});
} // if(data.CanBuy=='YES')
} // function check_someone_else_result
Now, in the show_for_someone_else() function, I'm redirecting to another page that loads another javascript file and I'm trying to set a javascript variable to the same value that I set the session variable to above.
<?php session_start(); ?>
var CART_URL = '{site_url}store/checkout/cart/';
$(document).ready(function(){
// attach the validationEngine to the form
$("#voucher_form").validationEngine('attach', {
scroll: false
}); // $("#voucher_form").validationEngine
// handles the NExt button click
$('#checkout-step-billing a').click(function(){
$('#checkout-step-billing .voucher_form').submit();
}); // $('#checkout-step-billing a').click
// handles keypresses in all the fields in the form to submit the
// form when the press enter
$("#checkout-step-billing .voucher_form input").keypress(function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$('#checkout-step-billing .voucher_form').submit();
return false;
} else {
return true;
}
}); // $("#checkout-step-billing .voucher_form input").keypress
// set the wait_list_flag from the session variable
var wait_list_flag = <?php $_SESSION['waiting_list_flag']; ?>
}); // $(document).ready
But I am not getting anything at all.
How do I need to do this?