Laravel 5 - weird sessions - laravel

in my application, after few requests, Laravel sessions randomly expired.
On my site, i had invalid links to images, i repaired them and everything works fine now.
What could be the problem? How could repairing links helped Laravel sessions from not being randomly deleted?

All your routes are inside middleware 'web' ? If you redirect to a route outside 'web' you loose sessions. Check that and return please.

Related

Laravel cache is creating issues

So we have an application in which we are using laravel and MySQL and we are facing laravel cache issues. For example, suppose if a user submits a form and we redirect back to the page with some value(flash session or any other data) then laravel is redirecting back to a cached page. If we reload the page then it shows the passed values, anything we do whether it is an update, insert or delete we have to reload it manually even though we redirect or reload the pages by code.
I don't know but I have tried to disable laravel cache but it is still not working.
Even i m calling Artisan commands for every request in my middleware:
Artisan::call('cache:clear');
Artisan::call('view:clear');
Artisan::call('route:clear');
But it's still now working.I m feeling helpless now.
Please help me :-(

laravel 5.6 random error "The page has expired due to inactivity"

My Laravel 5.6 project was working well.
But suddenly when I try to login sometimes it says
The page has expired due to inactivity.
and sometimes it login properly with out any error. For example
I go to page 127.0.0.1:8000/login...submit login form and get that error.
I refresh the 127.0.0.1:8000/login page...submit...again error.
I refresh the 127.0.0.1:8000/login page...submit and it works properly :|
Anybody know whats wrong with my project?!
this project works on my host without any problem and I have {{ csrf_field }} in my form.
I've tried to clear cache, view, route, config and deleting browser cache/cookie
and change SESSION_DRIVER=array but still got error.
UPDATE :
another thing that i should say is when it work properly and i login to the panel...when i submit any forms i got out of the panel and i should login again.
for localhost development open kernel.php inside Http folder and just comment this line :
\App\Http\Middleware\VerifyCsrfToken::class,
the csrf protection of laravel doesn't work properly on localhost. I already tried everything. just comment that, it's very annoying problem.
finaly...after 3 bad days focus on this issue...i find the answer and i hope it help someone else :
check your browser setting -> cookies and see how many cookies create
when a user login.
by default laravel create 2 cookies when user login with names :
"XSRF-TOKEN"
"laravel_session"
these are ok but other cookies which you create manually or other installed packages creates cause this problem.
i was using eloquent-viewable package and it creates a cookie everytime i logged in.
i remove this package and then everything works properly :)

Laravel 5.3 session cookies are not creating in browser

I am facing token mismatch issue in new server while working fine in localhost. I have tried every possible way to clear cache and give SESSION_DOMAIN path in env but all seems useless.
Also session cookies are not being created in web browser while creating in storage/framework/session folder.
Please help me !
Are you getting tokenMismatchException exception?
If yes, some of the possible reasons are:
Check your files for PHP end tag "?>", if exists remove it. For more detail refer to this link.
You may need to use web middleware. For more detail refer to this link (although it is about laravel 5.2 but, it may work for your situation too).
Another thing to try is checking for web middleware presence. Normally it should be automatically applied to routes/web.php
Route::group(['middleware' => ['web']], function () {
<routes>
});
Also check out https://laravel.com/docs/5.3/upgrade to see if you have any code that might have been influenced by this update.
And lastly, it would be nice if you could post a piece of code which is responsible for sessions in your app.

Laravel on a directory, links e.g. login link does not work

I have uploaded my Laravel app unto a directory under the public folder on my domain,
html_docs/public/store
where 'store' is the folder of my Laravel App. My main domain pointed at 'html_docs/public', please check my laravel app here "https://www.dinhi.org/store/". As you can see, when you click the "sell with us" or "login" on the top header, it returns
Not Found
The requested URL /store/dashboard/login was not found on this server.
I have set up to in my '.env' and in my 'config/app.php' the right url like "https://www.dinhi.org/store/" but still not working, any ideas, help please?
PS: I'm on Laravel 5.3 and I'm using Hesto Multi Auth. In my local, this issue does not exist like everything is good and working.
Laravel is not meant to be installed completely into the document root of your server. Actually, every folder of your laravel application except the public folder should be inaccessible from the web.
Your exposing yourself to a security risk here, since everybody could access every file of your app, including potential .env files with database credentials and the likes.
Cheers
Christoph

Laravel 5 and 4 in the same domain

My current situation is this.
My laravel 5 is here http://domain.com/cms (new project)
My laravel 4 is here http://domain.com/ (old assets)
If I login in http://domain.com/cms and then access the assets from http://domain.com/ (L4) then my cms then will be logged out.
I'm thinking maybe this has something to do with how was the session is being saved, I think they share the same session since they are in the same domain. But that is what I want to solved since they are 2 different project I just need the assets from the L4.
Hope someone can help me!
Thanks!
Chances are you need to change the cookie value in config/session.php (L5) and/or app/config/session.php (L4) to be separate.

Resources