YII2 Common page jump, as well as access to user information and login information and other information summary

Source: Internet
Author: User
Tags get ip yii

Reprint please indicate the original link address: http://www.niwoxuexi.com/blog/php/article/159.html

YII2 Common page jump, as well as access to user information and login information and other information summary

Current domain name Echo yii::app ()->request->hostinfo;

Current URL echo yii::app ()->request->geturl ();

Back home echo Yii::app ()->user->returnurl;

Prevent duplicate submissions after submission (CCONTROLER->REFRESH);
The previous page URL is very useful oh Yii::app ()->request->referrer;


Or: Yii::app ()->request->getreferrer ();

Get IP address Yii::app ()->request->userhostaddress;

Get insert ID after yii execute $id = Yii::app ()->db->getlastinsertid ();

Yii gets Get,post data Yii::app ()->request->getparam (' id ');
Yii->user (current user) related common methods are <span class= "Redactor-invisible-space" >yii:: $app->user;
User id</span> Yii:: $app->user->identity->id;
User name Yii:: $app->user->identity->username; <span class= "Redactor-invisible-space" >//Judge whether the user is logged in </span>yii:: $app->user->isguest
Tags:  yii2  yii2 page jump   YII2 user Information

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.