Yii Framework is logged on the home page and cannot be detected on other pages

Source: Internet
Author: User
Yii Framework on the home page is logged in, no other pages detected login
if (Yii::app ()->user->getisguest ()) {
$blog _model=new Blog ();
$blog _model->content=$_post[' content ';
$blog _model->title=$_post[' title ';
Date_default_timezone_set (' UTC ');
$blog _model->time=date ("y-m-d h:i:s");

if ($blog _model->save ()) {
$this->redirect (site_url. ' Blog/index ');
$this->renderpartial (' success ');
}
}else{
$this->renderpartial (' Error ');
}

This is in the blog interface, to determine whether to login, login to allow posting, but always said I did not log in, has actually logged in, to find a solution
------to solve the idea----------------------
Session is automatically open, get a print look
------to solve the idea----------------------
Reference:
if (Yii::app ()->user->getisguest ()) {
$blog _model=new Blog ();
$blog _model->content=$_post[' content ';
$blog _model->title=$_post[' title ';
Date_default_timezone_set (' UTC ');
$blog _model->time=date ("y-m-d h:i:s");

if ($blog _model->save ()) {
$this->redirect (site_url. ' Blog/index ');
$this->renderpartial (' success ');
}
}else{
$this->renderpartial (' Error ');
}

This is in the blog interface, to determine whether to login, login to allow posting, but always said I did not log in, has actually logged in, to find a solution

Yii::app ()->user->getisguest This piece of code means if the user is a tourist ...
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.