withPersistentSessions(true)->build(); $keyspace = 'glink'; $session = $cluster->connect($keyspace); $statement = $session->prepare('SELECT url FROM data WHERE shortlink=? ALLOW FILTERING;'); $result = $session->execute($statement,array('arguments' => array($uri))); if ($result->count() == 0) { printf('The given GLink was invalid, and doesn\'t point to a specific web page.'); exit; } foreach($result as $row) { if (is_null($row)) { printf('The given GLink was invalid, and doesn\'t point to a specific web page.'); exit; } else { header("Location: " . $row['url']); } } } ?>