YII 1.0 (7) Login Information Session use

Source: Internet
Author: User

Access to login information
Yii::app ()->user->name, transfer the login session information

$LoginForm->login () is called at logon to get the login user name

Pre-and post-session prefix settings

Note and the foreground distinguish, need to set: Inside the modules module inside the module.php Yii::app ()->setcomponents (Array ('      user ' = = Array (' Statekeyprefix ' = ' admin '),);

Session use

Storage: Yii::app ()->session[' logintime '] = time (); Call: Yii::app ()->session[' Logintime ']

Clear: Yii::app ()->session->clear (); Yii::app ()->session->destroy (); Exit Login: Yii::app ()->user->logout ();

Redirect Jump method use

If under current controller: $this->redirect (Array (' index '))//jump to the current controller index method to access other controller methods: $this->redirect (Array (' Controller/method ')

The CreateURL method uses

Use $this->createurl (' Controller/method ', get parameter) in the view, $this->createurl (' Article/index ', Array (' aid ' =>3));

Other

?>  Get the user name after login
?>  Get Client IP
?> getting a server environment
?>  Get PHP Version
?>  Get Server IP
?>  Database client Information
?> remaining space

Some usages in thinkphp
Server information        $con = mysql_connect (c (' Db_host '), C (' Db_user '), C (' db_pwd '));        $info = Array (            ' operating system ' = Php_os,            ' running environment ' = ' $_server[' server_software '),            ' PHP run as ' = Php_sapi_ Name (),            ' mysql version ' = Mysql_get_server_info (),            ' product name ' = =  king_appname,            ' product serial # ' and ' King_ ' BUILD,            ' upload attachments limit ' = Ini_get (' upload_max_filesize '),            ' execution time limit ' = Ini_get (' Max_execution_time '). "Seconds",            ' remaining space ' = Round ((@disk_free_space (".")/(1024 * 1024 *1024)), 2). ' GB ',        );        Mysql_close ($con);        $this->assign (' Server_info ', $info);



YII 1.0 (7) Login Information Session use

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.