1. In the program, whether it is a preview mode is implemented based on session. But when the user logs out, it will also automatically exit the preview mode. as shown in Figure 1

2. The performance of exiting the preview mode is that the preview banner at the bottom of the page has disappeared. as shown in Figure 2

3. Reference:session regenerate session id , if you use the built-in function LoginController, Laravel will automatically regenerate the Session ID in the authentication. The final decision is replaced with the corresponding cookie implementation
4. The replacement code is implemented in the following order
// $request->session()->forget(XxxService::THEME_PREVIEW_ID);
Cookie::queue(Cookie::forget(XxxService::THEME_PREVIEW_ID));
// $request->session()->put(XxxService::THEME_PREVIEW_NAME, $themePreviewName);
Cookie::queue(Cookie::make(XxxService::THEME_PREVIEW_NAME, $themePreviewName));
// $request->session()->forget([XxxService::THEME_PREVIEW_ID, XxxService::THEME_PREVIEW_NAME]);
Cookie::queue(Cookie::forget(XxxService::THEME_PREVIEW_ID));
Cookie::queue(Cookie::forget(XxxService::THEME_PREVIEW_NAME));
$request->session()->has(XxxService::THEME_PREVIEW_NAME);
Cookie::has(XxxService::THEME_PREVIEW_NAME);
$request->session()->get(XxxService::THEME_PREVIEW_NAME);
Cookie::get(XxxService::THEME_PREVIEW_NAME);
5. The test function is in line with the expectations. The newly set key has already existed in the cookie of the webpage after the jump. as shown in Figure 3

PHP / Laravel / Yii2 Legacy Project Maintenance & Long-Term Technical Support
If your PHP / Laravel / Yii2 project is already in production but needs bug fixing, API troubleshooting, performance optimization, developer handover support, or long-term maintenance, feel free to contact me for remote technical support.
Ideal For:
✅ PHP legacy systems without active maintenance
✅ Laravel / Yii2 project bug fixes
✅ Admin panel feature iterations
✅ RESTful API troubleshooting
✅ MySQL / Redis / Nginx performance issues
✅ Long-term remote part-time maintenance
We can start with a small task:
✅ Production error troubleshooting
✅ API issue analysis
✅ Slow query and performance bottleneck diagnosis
✅ Initial code structure review
✅ Deployment environment and log inspection
If you would like to discuss your project, please contact me and mention: PHP Maintenance Consultation.
Contact Me:
Telegram: @shuijingwan
WeChat: 13980074657
Email: shuijingwanwq@gmail.com

Leave a Reply