Yii method of obtaining system-level request parameters

Source: Internet
Author: User

First, Get/post

1. Get Data from Get/post

Yii::app ()->request->getparam (' id ');

2. Judge data submission method

Yii::app ()->request->ispostrequest;

Second, Session/cookie

1. Session Common operation

$_session equivalent to Yii::app ()->session;

1.1. Write session

// Start Session $session New chttpsession; $session, open (); Yii:: App ()->session[' key ' = ' value ';

1.2. Read session

Yii::app ()->session[' key '];

1.3. Get the session ID

Yii::app ()->session->sessionid

1.4. Destroy session

// Remove all Session variables Yii::app ()->session->Clear (); // removing data stored on the server side Yii::app ()->session->destroy ();

2. Cookies

2.1. Set Cookies

$cookie New Chttpcookie (' MyCookie ', ' This is my Cookie '); $cookie  Time () + 60*60*24*30; Yii$cookie;

2.2. Read cookies

$cookie = Yii::app ()->request->getcookies (); Echo $cookie [' MyCookie ']->values;

2.3. Destroying cookies

$cookie = Yii::app ()->request->getcookies (); unset ($cookie[$name]);

Source: http://my.oschina.net/jiangchike/blog/208696

Yii method of obtaining 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.