: This article mainly introduces Laravel, a top-level PHP Framework. (1) Laravel, a master-level framework, helps code become an art. if you are interested in PHP tutorials, refer to it. Common commands for laravel artisan:
Create a controller:
php artisan make:controller Front/Users/UsersController
Automatically created
./App/Http/Controllers/Front/Users/UsersController. php file
Common function code
1 Redirection
return Redirect('user/login');
2 session and cookie
Laravel uses file by default to implement session. She does not use php native$_SESSION
(Php native session depends on the position of php. ini), so ignore php-related session functions, such as session_start (), $ _ SESSION. Laravel will write session information in the app/storage/session/directory during running. Therefore, this directory requires write permission. Otherwise, the session cannot be written successfully.
Cookie operation:
Obtain the value in the Cookie:
Cookie::get('name');
Add a Cookie:
$response= Response::make('Hello World');response?>withCookie(Cookie::make(′name′,′value′,minutes));
If you want to set a Cookie before Response, use Cookie: queue ()
Cookie::queue(name,value, $minute);
Session operation:
Store a variable:
Session::put('key', 'value');
Read a variable:
Session::get('key');
Read a variable or return the default value:
Session::get('key', 'default');
Check whether a variable exists:
Sesssion::has('key');
Delete a variable:
Session::forget('key');
Delete all Session variables:
Session::flush;
Differences between cookie and session:
1. cookie data is stored in the client's browser, and session data is stored on the server.
2. cookies are not safe. others can analyze the cookies stored locally and perform cookie spoofing.
Session should be used for security consideration.
3. the session will be stored on the server for a certain period of time. When the number of accesses increases, it will occupy the performance of your server.
COOKIE should be used in consideration of reducing server performance.
4. data stored in a single cookie cannot exceed 4 kB. many browsers limit that a site can store up to 20 cookies.
5. personal suggestions:
Store important information such as login information as SESSION
Other information can be stored in the COOKIE if it needs to be retained.
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces Laravel, a top-level PHP Framework. (1) I first learned Laravel, a master-level framework, and made code an art, if you are interested in PHP tutorials.