Common Methods for yii to obtain system-level Request Parameters

Source: Internet
Author: User
Tags set cookie
1. Get/post 1.1, get data from get/post yii: APP ()-> request-> getparam ('id'); 1.2. Determine the data submission method yii:: APP ()-> request-> ispostrequest2, session/cookie 2.1, common session operations $ _ Session is equivalent to yii: APP ()-> session; 2.1.1 write session // start session $ session = new chttpsession; $ session-> open (); yii: APP () -> session ['key'] = 'value' 2.1.2. Read session yii: APP ()-> session ['key'] 2.1.3. Obtain session ID yii :: APP ()-> session-> sessionid 2.1.4. Destroy the session // remove all session variables yii: APP ()-> session-> clear (); // migrate the data stored on the server: yii: APP ()-> session-> destroy (); 2.1.5. session advanced usage $ session = yii: APP () -> session; $ session ['key'] = 'value'; var_dump ($ session ['key']); 2.2 cookie 2.2.1 set cookie $ cookie = new chttpcookie ('mycooker', 'This is my cooker'); $ cookie-> expire = Time () + 60*60*24*30; // there is a deadline of 30 days. yii: APP ()-> request-> Cookies ['mycookier'] = $ cookie; 2.2.2 Read cookie $ cookie = yii: APP ()-> request-> getcookies (); echo $ cookie ['mycookie ']-> value; 2.2.3 destroy cookie $ cookie = yii: APP ()-> request-> getcookies (); unset ($ cookie [$ name]);

 

Common Methods for yii to obtain system-level Request Parameters

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.