不要在历史记录,任何标题或元标记中保存URL? [英] Don't save URL in history, any header or meta-tag?
问题描述
是否可以使用任何HTTP标头或元标记来避免将URL添加到浏览器历史记录中?
Is there any HTTP-headers or meta-tags one can use to avoid getting a URL into the browser history?
例如,我不希望
http://domain.td/show/super-secret-unique-token-that-is-private
显示在浏览器的URL栏中。
to show up in the browser URL bar, when I start typing "domain.t".
目前我在网站上有一个(POST)搜索表单来加载令牌,但它们没有出现。但是后来我想通过链接加载令牌,比如让我们说一张专辑。
Currently I have a (POST) search form on the website to load the tokens, and they don't come up. But later I want to load the tokens via links, from let's say an album.
推荐答案
决定使用我保存的地图在浏览器会话中。通过这种方式,我可以将令牌密钥传递给URL,然后将变量返回。
Decided to use a map that I save in the browser session. This way i can pass the tokenKey throgh the URL and get the variable back afterwards.
我写了这个小的Zend_Session_Namespace扩展类并添加了'add'和'get'函数。
I wrote this little extended class of Zend_Session_Namespace and added 'add' and 'get' functions.
<?php
class My_Session_Tokens extends Zend_Session_Namespace {
protected $_namespace = "Tokens";
public function __construct($namespace = 'Tokens', $singleInstance = false)
{
parent::__construct($namespace, $singleInstance);
}
public function add($token) {
if($tokenKey = $this->hasToken($token)) {
return $tokenKey;
}
do { $tokenKey = uniqid(); } while(isset($this->$tokenKey));
$this->$tokenKey = $token;
return $tokenKey;
}
public function get($tokenKey) {
if(isset($tokenKey)) {
return $this->$tokenKey;
}
return null;
}
public function hasToken($token) {
foreach($this as $key => $val) {
if($val === $token) return $key;
}
return false;
}
}
这篇关于不要在历史记录,任何标题或元标记中保存URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!