简体   繁体   中英

Laravel sessions keep regenerating after upload to live server

I have recently deployed my new website to a shared hosting server.

I had to change some paths in order for it to work but in the end I got it all working, except for sessions.

The website behaves as if sessions are completely disabled. Upon closer inspection, using the "file" driver for sessions it creates many sessions in the storage/sessions folder.

I changed to the "database" driver and there was similar behaviour, many new rows/sessions being created after every page operation.

Does anyone have any idea what could be causing this?


Here's an example of one function that sets session variables:

public function addItem($itemId) {
    if (Session::get('cart.' . $itemId) !== null) {
        $quantity = Session::get('cart.' . $itemId) + Input::get('quantity');
    } else {
        $quantity = Input::get('quantity');
    }
    if (!Input::get('quantity'))
        $quantity = Session::get('cart.' . $itemId) + 1;
    Session::set('cart.' . $itemId, $quantity);
    $plural = (Input::get('quantity') > 1 ? Lang::get('messages.units') : Lang::get('messages.unit'));
    $msg = Input::get('quantity') . ' ' . $plural . ' '.Lang::get('messages.addedtocart').'!';

    if (Request::ajax()) {
        return Response::json(['quantity' => $quantity, 'message' => $msg]);
    } else {
        return Redirect::back()->with('message', $msg);
    }
}

I have found out what it is.

It appears that for some reason my ISP is stopping my sessions from working for whatever reason.

I switched to a VPN and all of a sudden all sessions work again. I noticed that other web apps like Google and SO were also behaving strangely.

Has anyone else encountered this before?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM