Source

RCircos / userSearch.php

<?php
$key = $_POST['key'];
$found = false;
// since cookies are stored as a hash of the session ID it is impossible to recreate the session ID from the cookie. The only way to do it
// is to check if hashes of any the existing session ID's matches the hash in the cookie.
foreach (glob('temp/' . '*') as $allfile1) {
	if(md5(substr($allfile1, 5)) == $key) {
		$found = true;
		$token = substr($allfile1, 5);
		echo "<script>var dis = document.getElementById('userID');
		var token = '$token';
		dis.type = \"hidden\";
		dis.value = token;
		dis = document.getElementById('username');
		dis.value = token;
		$('#circosForm').css('display', 'block');
		$('#preID').css('display', 'none');
		$(\"#ID\").html(token);
		$(\"#cookie\").html(\"<button type='button' onclick='Javascript: forgetCookie();'>Forget Cookie</button>\"); </script>";
	}
}
if($found == false) {
	echo "<script>window.alert('The id provided by your cookie does not match any existing sessions. It may have been deleted if it was unused for more than two weeks.');
	delete_cookie('rcircostoken');</script>";
}
?>