-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set_cookie - not working #1103
Comments
Cookie , No save action |
cookies are set later in the process. Can you provide info so I can recreate the problem, with sample code? Saying "it doesn't work" isn't really helpful :) |
` 1, 'msg' => 'success'])) } //-------------------------------------------------------------------- } ` @lonnieezell |
`<?php namespace App\Controllers; use CodeIgniter\Controller; class Save extends Controller
} |
The problem is that you're exiting the script before it has a chance to finish. Instead of existing, check out Setting the Output in the manual. Basically, do this instead:
|
Thanks very much |
@lonnieezell system/HTTP/Response.php;
|
Well - doesn't hurt anything :) Good catch. I'll take care of it, thanks. |
File: System/Helpers/cookie_helper.php
function set_cookie($name, string $value = '', string $expire = '', string $domain = '', string $path = '/', string $prefix = '', bool $secure = false, bool $httpOnly = false)
{
// The following line shows as a syntax error in NetBeans IDE
//(\Config\Services::response())->setcookie
$response = \Config\Services::response();
$response->setcookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httpOnly);
// Add
$response->sendCookies(); // public
}
File:/System/HTTP/Response.php
public function setCookie( .....) {
.....
$this->cookies[] = [
'name' => $prefix.$name,
'value' => $value,
'expires' => $expire,
'path' => $path,
'domain' => $domain,
'secure' => $secure,
'httponly' => $httponly,
];
}
@lonnieezell
The text was updated successfully, but these errors were encountered: