unserialize(): Error at offset 0 of 40 bytes - laravel

This Error comes When i try to server site login.
How to solve this error?

You have to set a news Key, use the following command:
php artisan key:generate
After that test again to run the Laravel Application
php artisan serve
See the similiar question: unserialize(): Error at offset 0 of 40 bytes Error

Laravel made a change to the way it handles cookies from V5.6.30 to improve security. It may be that you are trying to decrypt something that isn't serialized or vice versa.
First, Delete the cookies in your browser and/or clear your session-files in your Laravel app.
Or, within the middleware app\Http\Middleware\EncryptCookies.php, you can flip it to test:
add: protected static $serialize = true;
This is a pretty common question - you can search stack overflow for similar answers if this doesn't work.

Delete the cookies in your browser and/or clear your session-files in your Laravel app.
I got the same error, when I upgrade a Laravel 5.5 app to 5.6. The error comes form the EncryptCookies-Middleware.

This type of issue normally rise when you downgrade your Laravel version and a quick solution is I just clear my laravel and browser cache and it will work fine for me. Browser cache clear is mostly important.

Related

ErrorException - Trying to access array offset on value of type null in ServiceProvider.php line 84 in Lumen

I am new to Lumen so I just downloaded and installed a fresh lumen setup but unfortunately as soon as I hit postman it sends me above error. I have read many posts all says to use isset() i did so but still error persists therefore i request to help me.
Composer update also does not work.
Thanks!
It seems to be an issue between your version of PHP and Lumen 5.*
I found something here https://github.com/DarkaOnLine/SwaggerLume/issues/82
This worked for me
// in bootstrap/app.php
$app->configure('view');

Not working on Laravel Controller, Working on Tinker

Guzzle version(s) affected: 6.3 Laravel: 5.6.3 PHP: 7.2.10
Description
If I am trying to get response in tinker
$client = new \GuzzleHttp\Client();
$response = $client->get($url);
json_decode($response->getBody())
I am getting response as expected.
but in my controller
$object_res = $client->get($url);
I am getting error
"cURL error 3: malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)",…}
Which means, the url is incorrect, but as I have described, this working perfectly in tinker.
Note
I am getting everything working perfectly in my localhost, this is occurring only on my test server.
Please let me know, if I need to give additional information.
Tinker uses a different runtime than your application, this could be causing an issue because in one scenario. php goes directly from your box to the api server and in the other it goes through your webserver before making the request.
The first thing to do would be to clear your laravel cache and config with
php artisan cache:clear
and
php artisan config:clear
if that fails I would look into the cross-domain restrictions or settings on your web server.
Please check for Guzzle requirements on your server. specially
To use the PHP stream handler, allow_url_fopen must be enabled in your system's php.ini.
I just ran into this problem on my testing server, I found it using cockpit. but my problem was with alouy/youtube. check selinux if you have that on your production server. check file permission of .env too. Hard to give a solution when the variables of your server are not presented.
also Read your laravel logs, that presented the solution to me.
hope this helps.

Postman not Working with Laravel Valet (Local)

When I use Postman to send or get data to/from my local Laravel applications it always returns the error...
Could not get any response.
For example, a GET request to
http://demo_app.localhost/api/data.
I use Laravel Valet on my Mac. It looks like Postman can't find the local domain.
I had the same issue when trying to use valet with Postman and what fixed it for me was turning off the SSL verification in Settings > General. I believe valet is using some internal SSL certificate by default that cannot be verified properly by Postman.
Use TLD .test, if your Valet version is up-to-date and not specifically configured to use .localhost.
Should be like http://demo_app.test/api/data
See official docs for background:
Valet documentation at chapter "Using Another Domain".
I had the same issue and used all the suggestion above, none of them works.
For my case, I used the following command to fix the problem:
php artisan optimize
This clears the cache and config files and reloads the new api Routes added to the Laravel framework.

Why Laravel project website response is over 10 seconds long on artisan localhost only?

When I work with my local version of project then every action taken on website needs around 10 seconds long response. It's so frustraiting. And it hapens only on my PC. How can I prevent this action?? Downloading project from VCS to new folder helps for short time. I have Windows 10, Laravel 5.4, PHP 7.0.15. Commands
php artisan cache:clear
and
php artisan optimize
are not helping. Please, can anyone help?
Do you use xdebug? It can slow down application.
Also check your laravel debug option in .env file, it should be:
APP_DEBUG=false
That was laravel.log. I deleted it and everything seems to be ok. The file had 56MB of logs. Now i have to find out how to stop logging or create new log file every 2MB.

Laravel caching old controllers MAMP

I have a Laravel application that refuses to acknowledge controller changes even if the controller doesn't exist anymore!
Using MAMP PRO 5.5.3 and Laravel 4.1
with
/Applications/MAMP/bin/php/php5.5.3/bin/php
I have followed these instructions
Stop caching for PHP 5.5.3 in MAMP
I have deleted the view storage in Laravel.
There was mention of adding - opcache_reset(); in my bootstrap/autoload.php
http://laravel.io/forum/02-06-2014-laravel-and-view-caching-in-development-cant-see-changes-right-away
But not sure how and where you do you do that, I tried but just got an error
Call to undefined function opcache_reset()
The caching still continues!
Despite the controller having been deleted 2 hours ago (to prove controller not being called), it is still showing the page with an imaginary controller.
It's driving me insane.
Any help really appreciated.
Further to this the route file is refusing to accept UserController
Route::get('register', 'UserController#getRegister');
Giving this error
.....controllers/UserControllerb.php): failed to open stream: No such file or directory
UserControllerb.php doesn't exist and was not asked for ?! but the route is wrongly looking for it
When I try this
Route::get('register', 'UserControllerb#getRegister');
Rightly give this error
Class UserControllerb does not exist
So the route has been cached (a previous back-up removed days ago)
I have tried to use composer which decides it doesn't want to work and no-one seems to know the solution for either problem.
Laravel composer signal "11" error symfony osx
Huge kudos to anyone who can solve this.

Resources