Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

prudhvi259's avatar

DecryptException in BaseEncrypter.php line 48: The MAC is invalid. in laravel 5.2

I am getting this error when i sent a post request to my resource controller. My controller code is

public function store(Request $request)
{
    //return $request->all(); (here i am checking values sometimes showing values and sometimes showing the mac error.)
    $tags = $request->input('tags');
        if(!empty($tags)){
            $tags = implode(",", $tags);
        }
    //return $request->from;
    $status = FamousPost::create([

        'name' => $request->input('from'),
        'to_name' => $request->input('to'),
        'title' => $request->input('title'),
        'content' => $request->input('content'),
        'avatar' => $request->input('from_avatar'),
        'to_avatar' => $request->input('to_avatar'),
        'tags' => $tags

    ]);

    if($status)
        return json_encode(true);
    else
        return json_encode(false);
}

Sometimes values are coming from request and sometimes(mostly) i am getting the mca error. My frontend is angularjs i am submitting the form using $http service of angularjs.

0 likes
2 replies
prudhvi259's avatar

@tisuchi thanks for your reply. i will check your link. One more thing after changing my session cookie form laravel_session to myapp_session my session worked perfectly but at my firsttime login it is showing TokenMismatchException in VerifyCsrfToken.php line 67: error and after refresh everything is working fine.

Please or to participate in this conversation.