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

riskiansyah's avatar

created cookie value not same as provided value

Hello,

I have kind of problem: The controller that I create has cURL to flarum API for creating a login function via cookie. But the result kinda weird since provided value for cookie return wrong value.

The example of controller have this snippet:

$api_url = "https://example.co/api/token";

$username = $req->user()->email;

$password = $req->password;

// CURL call

$ch = curl_init($api_url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['identification' => $username,'password' => $password]));

$result = curl_exec($ch);

$flsession = json_decode($result);

$expire = 43200; // a month

$kue = cookie('flarum_remember', $flsession->token, $expire, "/", "example.co", true, true);

Trying to call $flsession->token would be generate token like this : 5cqPzZM4N2QT6BlqHWSHV76YJj5KszhadQWrF82F But returning view like this: return view('forum')->withCookie($kue); just return a new cookie with correct name, expiration, path, domain, http true and secured, but the value is something like this : eyJpdiI6Ijh6NHRsRFd6Y2c4UXBROG03U1wveTdBPT0iLCJ2YWx1ZSI6IkhqNHZlcmxYekNaRFdGTUw1VzJlM0xMK1g3UUdYdEJRRkp4ZmRZZGx4MitoWU5yNEdmT1wvYlwvUFk4SWhvek1xN0dFcDRnVHRFXC9sZEFiSEduaEFDcXB3PT0iLCJtYWMiOiI0NzcxYTdiY2I2NDI5OTAwNGZiNTU2NmNmZWIyMDM0ODBkNGQ0YTRkNTVjZjZkZGE1YzQ3NzkzZjE2MjEyMmI0In0%3D

What step missing on it ? please help...

Thanks before

0 likes
1 reply

Please or to participate in this conversation.