My question can look stupid but I need to get in touch and get a decision. I want to pass parameters to url without the parameters being seen in the url. this is to secure my server. Because the url looks like this
我的问题看起来很愚蠢,但我需要联系并做出决定。我想将参数传递给url,而不会在url中看到参数。这是为了保护我的服务器。因为网址看起来像这样
controller/edit/123
控制器/编辑/ 123
and the '123' is the user ID in the database. I can simple do this
'123'是数据库中的用户ID。我可以这么简单
public function action_edit($id) {
get_db_info($id);
}
Is it possible to hide the parameter while redirecting to this url from a view? ie in the view file
从视图重定向到此URL时是否可以隐藏参数?即在视图文件中
// Do something to set the ID
<?php Kohana_Request::post("user_id", $id); ?>
<a href="<?=URL::base()?>controller/edit">Click</a>
and get the ID like this
并获得这样的ID
public function action_edit() {
$id = $this->request->post("user_id");
get_db_info($id);
}
But the problem I can't access the KOhana_Request instance and get this error
但问题是我无法访问KOhana_Request实例并得到此错误
*Non-static method Kohana_Request::post() should not be called statically*
*非静态方法Kohana_Request :: post()不应静态调用*
Can someone gives a secured approach to this ?
有人可以给出一个安全的方法吗?
1 个解决方案
#1
0
I think I found a solution by encoding and decoding the parameters.
我想通过编码和解码参数找到了解决方案。
Since Kohana 3.3 do not allow parameters in controller functions see .
由于Kohana 3.3不允许控制器功能中的参数,请参阅。
I do this in my view
我认为这样做
$user_id = Encrypt::instance()->encode($liste->user_id);
$encode_id = base64_encode($user_id);
$encode_ure_id = urlencode($encode_id);
And from the controller,
从控制器,
$encoded_id = urldecode($this->request->param('uri_id'));
$encode_base_url = base64_decode($encoded_id);
$user_id = Encrypt::instance()->decode($encode_base_url);
If this can help others.
如果这可以帮助别人。
#1
0
I think I found a solution by encoding and decoding the parameters.
我想通过编码和解码参数找到了解决方案。
Since Kohana 3.3 do not allow parameters in controller functions see .
由于Kohana 3.3不允许控制器功能中的参数,请参阅。
I do this in my view
我认为这样做
$user_id = Encrypt::instance()->encode($liste->user_id);
$encode_id = base64_encode($user_id);
$encode_ure_id = urlencode($encode_id);
And from the controller,
从控制器,
$encoded_id = urldecode($this->request->param('uri_id'));
$encode_base_url = base64_decode($encoded_id);
$user_id = Encrypt::instance()->decode($encode_base_url);
If this can help others.
如果这可以帮助别人。