I'm trying to create a cookie with codeigniter for like 2 days -.- (I was to ashame to ask the question before...)
Anyone care to explain me what is wrong with this code:
$websiteUrl = preg_replace("/^[\w]{2,6}:\/\/([\w\d\.\-]+).*$/","$1", base_url());
$this->load->helper('cookie');
$cookie = array(
'name' => 'rememberMe',
'value' => $this->encrypt->encode(serialize($serialize)),
'expire' => (time() + $this->config->item('remember_me')),
'domain' => '.'.$websiteUrl,
'path' => '/',
'prefix' => 'chv_',
'secure' => false,
);
set_cookie($cookie);
$this->input->set_cookie($cookie)
($this is CI instance)
Docs: http://codeigniter.com/user_guide/helpers/cookie_helper.html
Make sure $this->config->item('remember_me') > 0
I was working with CI many times and i was always using native setcookie() function, because i really don't need any framework to set cookie (it's simple operation)... But according to documentation using CI instance and input CI->input->set_cookie() should do the job. Remember NO FRAMEWORK is 100% perfect working... It's only framework... You can debug step-by-step CI code to see what happens.
(from comment)
Make sure that there is no extra whitespace being loaded before you are running set_cookie that is preventing the cookie header from being sent to the browser. I have spent many an hour tracking down that issue and found i had an extra space at the end of a closing tag somewhere. If you turn E_WARNING on, this should reveal the issue.
Related
I need to debug some errors and formatting within a professional wordpress site. I need to do the debugging from the raw code. It is mostly php and JS. I have ended up with more than 2million lines of code after the most recent update. There are some empty box space on the home page and a list of bugs from the WP_DEBUG log.
This is my first time working with Wordpress at all. I am overwhelmed by the amount of code, and can't figure out where any of the bugs and issues are. I have worked with Angular Typescript in the past.
I would assume, to an extent, that some of these issues would be able to be fixed within the 'drag and drop' API of wordpress, but I have no idea how to use that either, when there is an already several million lined website code, and like I said, I was given the raw php code of over 2 mil lines to debug with.
I have been using VS code for the editor and MAMP as a live server.
I have no idea where to start, and I have not been able to find any useful tutorials online. Any help is greatly appreciated. I could really just use some guidance on how this process might work. Or if it even is something that people do, ever. It looks like according to the internet, this may not be the way to go about debugging. Feel free to ask questions I'll try to answer anything I can without giving away any confidential info.
Here are the bugs that show up on the site from WP_Debug:
Warning: preg_match(): No ending delimiter '*' found in C:\repos\website\wp-content\mu-plugins\no-cache.php on line 8
Warning: preg_match(): Empty regular expression in C:\repos\website\wp-content\mu-plugins\no-cache.php on line 8
Notice: Trying to get property 'Location' of non-object in C:\repos\website\wp-content\themes\Child-Theme\functions.php on line 45
Notice: Trying to get property 'Subrole' of non-object in C:\repos\website\wp-content\themes\Child-Theme\functions.php on line 46
Update: I am still having issues with these same errors. I am looking for assistance on how the process of debugging raw WP php code works, and if I am trying the right things. I can provide the code that a few errors are pointing to, but I do have to adjust the variables to maintain confidentiality.
\Child-Theme\functions.php (35-50):
if(class_exists(\RoleList\RoleList::class)) {
wp_localize_script('site-name', 'SiteName', [
'RoleList' => [
'categories' => $role_categories,
'locations' => \RoleList\Categories::getLocations(),
'category_counts' => \RoleList\Listings::getCategoryCounts(),
],
'CurrentRole' => [
'is_role_page' => ($listing ? true : false),
'current_category' => ($current_category ? $current_category : null),
'current_location' => ($listing->Location ? $listing->Location : null),
'current_subrole' => ($listing->Subrole ? $listing->Subrole : null),
'home_url' => home_url(),
]
]);
}
For one of my Selenium Cests I want to set a cookie but this is simply not working. In order to find the problem I reduced my code to the absolut minimum and to my surprise setting cookies seems not to work at all.
/**
* Test if we can set simple cookies
*
* #param \AcceptanceTester $i
* #throws Exception
*/
public function settingCookieSetsCookie(AcceptanceTester $i)
{
$cookieDefaultParams = [
'path' => '/',
'secure' => false,
'httpOnly' => false,
'expiry' => 900,
'domain' => 'www.testdomain.local'
];
$i->amOnPage('/cookieCest.php');
$i->setCookie('example', 'myvalue', $cookieDefaultParams);
$i->amOnPage('/cookieCest.php'); // reload page
$cookieValue = $i->grabCookie('example');
$i->assertEquals('myvalue', $cookieValue);
}
For testing purposes I set up a local test domain www.testdomain.local which works fine.
Unfortunately the above test fails with the following error:
There was 1 failure:
1) BackendLoginCest: Setting cookie sets cookie Test codeception\acceptance\CookieCest.php:settingCookieSetsCookie Step
Assert equals "myvalue",null Fail Failed asserting that null matches
expected 'myvalue'.
Scenario Steps:
$I->assertEquals("myvalue",null) at codeception\acceptance\CookieCest.php:36
$I->grabCookie("example") at codeception\acceptance\CookieCest.php:35
$I->amOnPage("/cookieCest.php") at codeception\acceptance\CookieCest.php:34
$I->setCookie("example","myvalue",{"path":"/","secure":false,"httpOnly":false,"expiry":900,"domain":"www.new-ep...})
at codeception\acceptance\CookieCest.php:33
$I->amOnPage("/cookieCest.php") at codeception\acceptance\CookieCest.php:32
FAILURES! Tests: 1, Assertions: 1, Failures: 1.`
As far as I can see the cookie params configuration looks good (and seems to be needed, as leaving it out results in an error).
I am currently using selenium-server-standalone-3.141.59.jar but tried older versions which produce the same problem.
The referenced file cookieCest.php is just a simple script which var_dumps $_COOKIE so I can see that there are no cookie values available in PHP.
Does anyone experience a similar problem and knows how to handle it?
Your code should work. What may be a solution is that the page is not loaded when you want to set the cookie so it fails there.
Also if you want to check your cookie you can use the function seeCookie like:
Try this solution and let me know if it did any change.
$i->amOnPage('/cookieCest.php');
$i->wait(5);
$i->setCookie('example', 'myvalue', $cookieDefaultParams);
$i->seeCookie('example');
Try this test with older Chrome version (e.g. 66).
I think all cookie related stuff are broken with last several Chrome versions.
When I forget to translate something, somewhere Project VIEW, I change the file /app/Locale/por/LC_MESSAGES/default.po and sending it back to the server.
But mostly, this 'new translation', takes HOURS to be viewed, in short: I just send the file, cleaned the cache and browser CakePHP, press F5, and ... NOTHING HAPPENS.
For what reason?
[EDIT]
<?php echo $this->Form->input('Item.0.description', array('label' => false,
'class' => 'span12', 'div' => array('class' => 'span7'), 'rows' => 3,
'placeholder' => __('Type the description'))); ?>
To force the language to update you can clear the persistent and models directories in the /tmp/cache directory. If view caching is enabled you'll have to clean out views as well.
Caching is disabled when debug is set to 2 (which is the value for using the framework during development) and the persistent directory is populated with new cache files, overwriting the old ones each time a view is loaded. So the debug switch and subsequent browser refresh might clean the old language files for you.
I found a strange solution:
I set (app/Config/core.php)...
Configure::write('debug', 2); // It was 0
Press, F5... wait... and works.
Later, I back...
Configure::write('debug', 0);
Press F5 again, and works.
Why? I no have idea.
Even if Configure::write('debug', 2); I recommend to delete the remote folder containing the translations, refresh with browser (to state that nothing is translated anymore) then reupload the translations folder.
Works perfectly that way for me.
I am developing activecollab custom module; facing an issue related to Routers.
I by mistake type wrong action name in Router's action where we need to define in router, but after getting error I updated that action name but activecollabs still reading a previous action i removed files from cache and complie folders but reading previous action.
please share if you ever face this problem in development of activecollab module..
By mistake I did this: (action=>'views')
Router::map('mymodule_view', 'mymodule/view/:request_id', array('controller' => 'mymodule', 'action' => 'views' ), array('req_id' => Router::MATCH_ID) );
but after getting error i update above code by this: (action=>'views')
Router::map('mymodule_view', 'mymodule/view/:request_id', array('controller' => 'mymodule', 'action' => 'view' ), array('req_id' => Router::MATCH_ID) );
First, make sure that your system is in development mode. Open config/config.php and confirm that APPLICATION_MODE is set to in_development:
define('APPLICATION_MODE', 'in_development');
Now that you have that covered, go to activeCollab and you'll have Developer toolbar available in the lower right corner of the application interface, next to activeCollab powered button (it has a red bug icon). Use this tool to clear cache, rebuild images etc.
PS: You can also clear all files from /cache folder, just in case.
I migrated a cake website from one server to another, but in statics pages is showing a blank page, this is happening in two case scenarios right now
Scenario1:
$this->redirect(Router::url(array('controller' => 'staticpages',
'action' => 'message', 'messageSlug' => 'welcome')));
Scenario2:
$link = Router::url(array('controller' => 'staticpages',
'action' => 'message', 'messageSlug' => 'thanks-for-registering'));
The Facebook PHP SDK is interfering. It's probably throwing an error before Cake can properly redirect (the headers are already sent by groofi__extra_facebook.php.
Have a look what's happening in groofi__extra_facebook.php where the error seems to be stemming from. Probably your new server configuration is missing a vital component, is cURL present, for example?