[英]Codeigniter how can I make this route work
I've looked around in the documentation and a few other places and I am not sure how to achieve the results I want. 我在文档中和其他一些地方四处查看,但不确定如何获得所需的结果。 I have a domain name set up that will only server public profile pages to visitor.
我设置了一个域名,该域名仅将公共配置文件页面提供给访问者。 When someone comes straight to the site I want it to display a welcome screen telling more about what the website is about.
当有人直接访问该网站时,我希望它显示一个欢迎屏幕,告诉您有关该网站的更多信息。 (example.com) When someone visits example.com/my-public-page I want it to run a default controller that grabs the 'my-public-page from the url, searches the database for a user with that info in a column and displays their info.
(example.com)当某人访问example.com/my-public-page时,我希望它运行一个默认控制器,该控制器从URL中获取“ my-public-page”,然后在数据库中搜索具有该信息的用户并显示其信息。
I would image that I just set the default_controller to my controller and then check for a second string in the url. 我会想像一下,我只是将default_controller设置为控制器,然后在url中检查第二个字符串。 If its present search for that in the database.
如果其当前在数据库中搜索。 After looking around I am not sure how to make this work and not sure what to search for to get the results I need.
环顾四周后,我不确定如何使它工作,也不确定要搜索什么才能获得所需的结果。
Thanks for your help, 谢谢你的帮助,
After defining an encryption key for sessions in config.php you can use something like this: 在config.php中为会话定义加密密钥后,您可以使用以下代码:
class Wellcome extends CI_Controller {
public function __construct() {
parent::__construct();
$this -> load -> library('session');
if(!$this->session->userdata('visit_time')) {
$this->session->set_userdata('visit_time', time());
redirect('first_visit');
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.