for another page you can use $_SESSION
<script type="text/javascript">
var timestamp = 0;
var currentroom = <?php echo $_SESSION['room']; ?>;
var heartbeatTimer;
var minHeartbeat = 3000;
var maxHeartbeat = 12000;
</script>
For same file/script sequence- its very simple, no need of SESSION
var currentroom = <?php echo $room; ?>;