Session is create and print in backend but not work in frontend

馋奶兔 提交于 2019-12-24 09:58:05

问题


I am facing some strange issue.

This problem happens on server. I am facing this problem since last 5-6 days. It was working for me until last 1 year.

When I call a login api, if user credential is right then I create a session.

Here is my code:

if ($user){
    if ($user['is_active'] == 1){
        global $user_data;
        $user_data = $user;
        $response["error"] = false;
        $_SESSION['user_data'] = $user; // -- session is create
        print_r($_SESSION); // session is print.

        $_SESSION['is_login'] = 'No';
        unset($_SESSION['sessionX']);
        $response['user_id'] = $user['user_id'];
        $response['name'] = $user['name'];
        $response['email'] = $user['email'];
        $response['apiKey'] = $user['api_key'];
        $response['createdAt'] = $user['created_date'];

    } else {
        $response['error'] = true;
        $response['message'] = 'Your Account is Not Active';
    }
} else {
// user credentials are wrong
    $response['error'] = true;
    $response['message'] = 'Login failed. Incorrect credentials';
}

print_r of this portion:

Array
(
    [slim.flash] => Array
        (
        )

    [db_name] => arcade_intecigar
    [user_data] => Array
        (
            [user_id] => 1
            [name] => zzz
            [email] => zzz@abc.com
            [api_key] => 3fef39209b3d03039cdb81d39566eb66
            [lang_id] => en_US
            [created_date] => 0000-00-00 00:00:00
            [profile_pic] => ""
            [img] => 1461269872mk-ok.png
            [subscription_id] => 20
            [is_active] => 1
            [role_id] => 1
            [delete_permission] => 1
            [phone_number] => +14507013
            [country_code] => 1
            [total_usage_funds] => 0.0024999999441206
            [total_available_funds] => 0.99750000238419
            [paid] => trial
            [currency] => USD
        )

)

After login, I am redirecting my app to dashboard page and check that if session is available or not, but it is strange that session is not available. And it is always redirecting me to the login page.

Look below code.

print_r($_SESSION); // it is display a blank
if (!isset($_SESSION['is_login']) && !isset($_SESSION['is_lock'])) {
    echo "<script>window.location='" . SITE_URL . "login.php?redirect=" . $_SERVER['REQUEST_URI'] . "';</script>";
}
if (isset($_SESSION['is_login']) && $_SESSION['is_login'] == 'NO' || $_SESSION['is_login']== 'No') {
    echo "<script>window.location='" . SITE_URL . "login.php?redirect=" . $_SERVER['REQUEST_URI'] . "';</script>";
}   

print_r of this portion:

Array ( [db_name] => arcade_intecigar ) 

回答1:


This problem is happen because , on server there is no inode memory is avaiable for more session create , as per my knowledge when session is create in php that time session file is also create , so there is no memory is available that's why session is not create .

Use df -i command for know the inode memory on server.

Check this link for more description: https://www.ivankuznetsov.com/2010/02/no-space-left-on-device-running-out-of-inodes.html



来源:https://stackoverflow.com/questions/39284474/session-is-create-and-print-in-backend-but-not-work-in-frontend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!