Yii – Sessions
Sessions make data accessible across various pages. A session creates a file on the server in a temporary directory where all session variables are stored. This data is available to…
Sessions make data accessible across various pages. A session creates a file on the server in a temporary directory where all session variables are stored. This data is available to…
The username validation should only be done on the server side because only the server has the needed information. In this case, you can use AJAX-based validation. Step 1 − To…
Sometimes you need to validate values that are not bound to any model. You can use the yii\base\DynamicModel class, which supports defining both attributes and rules on the fly. Step 1 − Add…
You should never trust the data received from users. To validate a model with user inputs, you should call yii\base\Model::validate() method. It returns a Boolean value if the validation succeeds. If there…
When a form is based upon a model, the common way of creating this form in Yii is via the yii\widgets\ActiveForm class. In most cases, a form has a corresponding model which…
A URL rule is an instance if yii\web\UrlRule. The urlManager components uses the URL rules declared in its rules property when the pretty URL format is enabled. To parse a request, the URL manager obtains…
To change the default route of the application, you should configure the defaultRoute property. Step 1 − Modify the config/web.php file in the following way. <?php $params = require(__DIR__ . '/params.php'); $config = [ 'id'…
When a Yii application processes a requested URL, first, it parses the URL into a route. Then, to handle the request, this route is used to instantiate the corresponding controller…
When a web application handles a request, it generates a response object, which contains HTTP headers, body, and HTTP status code. In most cases, you will use the response application…
Extensions are packages specifically designed to be used in Yii applications. You can share your own code as an extension or use third-party extensions to add features to your application.…