> -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions.
> To unsubscribe from this group, send email to > cake-php+unsubscribe@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php
Right, so in the example I was mainly just wanting to show that I was reaching those points in the code. Theoretically, if I remove the "print 'before redirect';" statement then I should never see "after redirect" but I should see "in the index" upon the new page load (since that is post redirect).
For some reason, I was still unable to redirect when I wasn't printing to the screen before the call to exit. However, I may have just been tired and didn't realize I still had a print before exit. So I'll try again and respond back with the results.
On Mon, Mar 19, 2012 at 10:56 AM, glevine <levine.g...@gmail.com> wrote: > Right, so in the example I was mainly just wanting to show that I was > reaching those points in the code. Theoretically, if I remove the "print > 'before redirect';" statement then I should never see "after redirect" but > I should see "in the index" upon the new page load (since that is post > redirect).
> For some reason, I was still unable to redirect when I wasn't printing to > the screen before the call to exit. However, I may have just been tired and > didn't realize I still had a print before exit. So I'll try again and > respond back with the results.
> Thanks
> On Monday, March 19, 2012 7:56:28 AM UTC-4, euromark wrote:
>> no you can't! or: you really shoudn't >> you should simply do everything before redirecting.
>> theoretically, you can manually call exit() if you set the exit param to >> false on redirect. >> but to me this makes no sense.
>> >> can we do some process after redirect.
>> -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions.
> To unsubscribe from this group, send email to > cake-php+unsubscribe@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php
On Monday, March 19, 2012 7:56:09 AM UTC-7, glevine wrote:
> Right, so in the example I was mainly just wanting to show that I was > reaching those points in the code. Theoretically, if I remove the "print > 'before redirect';" statement then I should never see "after redirect" but > I should see "in the index" upon the new page load (since that is post > redirect).
> For some reason, I was still unable to redirect when I wasn't printing to > the screen before the call to exit. However, I may have just been tired and > didn't realize I still had a print before exit. So I'll try again and > respond back with the results.
> Thanks
> On Monday, March 19, 2012 7:56:28 AM UTC-4, euromark wrote:
>> no you can't! or: you really shoudn't >> you should simply do everything before redirecting.
>> theoretically, you can manually call exit() if you set the exit param to >> false on redirect. >> but to me this makes no sense.
Commenting out the print statements in the change method has no effect. I never see the "in the index" print statement and the browser simply shows a blank page with a couple of warnings about changing the salt and cipherSeed. The url in the location bar remains http://www.example.com/tests/change.
> On Monday, March 19, 2012 7:56:09 AM UTC-7, glevine wrote:
>> Right, so in the example I was mainly just wanting to show that I was >> reaching those points in the code. Theoretically, if I remove the "print >> 'before redirect';" statement then I should never see "after redirect" but >> I should see "in the index" upon the new page load (since that is post >> redirect).
>> For some reason, I was still unable to redirect when I wasn't printing to >> the screen before the call to exit. However, I may have just been tired and >> didn't realize I still had a print before exit. So I'll try again and >> respond back with the results.
>> Thanks
>> On Monday, March 19, 2012 7:56:28 AM UTC-4, euromark wrote:
>>> no you can't! or: you really shoudn't >>> you should simply do everything before redirecting.
>>> theoretically, you can manually call exit() if you set the exit param to >>> false on redirect. >>> but to me this makes no sense.
First off, change your core configuration so you aren't using the default salt and cipherSeed (this can be found in your apps core.php file in the Config folder), that is if this app matters which it seems like it is just a practice app but still good practice. It appears your routes(app Config folder, routes.php) are set so that when you visit your tests index it will direct you towards the default home page that is set in the cake core. I recommend modifying this, so that when people visit your index (/) it is routed to the controller and action of your choice. Which in this case seems to be tests controller and action index. The line of code will look like this Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); Modify it to Router::connect('/', array('controller' => 'tests', 'action' => 'index'); For the record, it is not recommended to use print when debugging, if you just want to do browser debugging use cakes debug function. You can use it anywhere, and it accepts any type of variable and will output it cleanly.
On Monday, March 19, 2012 6:41:51 PM UTC-7, glevine wrote:
> @thatsgreat2345 That was just a typo.
> Commenting out the print statements in the change method has no effect. I > never see the "in the index" print statement and the browser simply shows a > blank page with a couple of warnings about changing the salt and > cipherSeed. The url in the location bar remains > http://www.example.com/tests/change.
> On Monday, March 19, 2012 3:53:44 PM UTC-4, thatsgreat2345 wrote:
>> Your problem is you are redirecting to test controller when in fact you >> should be redirecting to tests controller.
>> On Monday, March 19, 2012 7:56:09 AM UTC-7, glevine wrote:
>>> Right, so in the example I was mainly just wanting to show that I was >>> reaching those points in the code. Theoretically, if I remove the "print >>> 'before redirect';" statement then I should never see "after redirect" but >>> I should see "in the index" upon the new page load (since that is post >>> redirect).
>>> For some reason, I was still unable to redirect when I wasn't printing >>> to the screen before the call to exit. However, I may have just been tired >>> and didn't realize I still had a print before exit. So I'll try again and >>> respond back with the results.
>>> Thanks
>>> On Monday, March 19, 2012 7:56:28 AM UTC-4, euromark wrote:
>>>> no you can't! or: you really shoudn't >>>> you should simply do everything before redirecting.
>>>> theoretically, you can manually call exit() if you set the exit param >>>> to false on redirect. >>>> but to me this makes no sense.
On Tuesday, 20 March 2012 02:41:51 UTC+1, glevine wrote:
> @thatsgreat2345 That was just a typo.
> Commenting out the print statements in the change method has no effect. I > never see the "in the index" print statement and the browser simply shows a > blank page with a couple of warnings about changing the salt and cipherSeed.
Read this aloud "You can not send output to the webpage and then redirect."
On Tuesday, March 20, 2012 3:41:51 AM UTC+2, glevine wrote:
> @thatsgreat2345 That was just a typo.
> Commenting out the print statements in the change method has no effect. I > never see the "in the index" print statement and the browser simply shows a > blank page with a couple of warnings about changing the salt and > cipherSeed. The url in the location bar remains > http://www.example.com/tests/change.
> On Monday, March 19, 2012 3:53:44 PM UTC-4, thatsgreat2345 wrote:
>> Your problem is you are redirecting to test controller when in fact you >> should be redirecting to tests controller.
>> On Monday, March 19, 2012 7:56:09 AM UTC-7, glevine wrote:
>>> Right, so in the example I was mainly just wanting to show that I was >>> reaching those points in the code. Theoretically, if I remove the "print >>> 'before redirect';" statement then I should never see "after redirect" but >>> I should see "in the index" upon the new page load (since that is post >>> redirect).
>>> For some reason, I was still unable to redirect when I wasn't printing >>> to the screen before the call to exit. However, I may have just been tired >>> and didn't realize I still had a print before exit. So I'll try again and >>> respond back with the results.
>>> Thanks
>>> On Monday, March 19, 2012 7:56:28 AM UTC-4, euromark wrote:
>>>> no you can't! or: you really shoudn't >>>> you should simply do everything before redirecting.
>>>> theoretically, you can manually call exit() if you set the exit param >>>> to false on redirect. >>>> but to me this makes no sense.
guys. if you want to crappy debug here, use DIE();
die('before redirect');
$this->redirect(array('controller' => 'test', 'action' => 'index'));
die('after redirect'); // totally nonsense, because it will NEVER reach this point
echo creates problems - and doesnt solve any!
if you want to NOT crappy debug with redirects, use something else, like log():
$this->log('some log entry', 'test');
and look into /tmp/logs/test.log
Am Dienstag, 20. März 2012 11:23:29 UTC+1 schrieb pokerphp:
Initially, I had a print statement before the redirect left over from when I was tracing the code path down to the header() call. After commenting out all print statements except the one in index(), I still don't successfully redirect. That print statement shouldn't be called until after the redirect has occurred. So unless you can explain why any output from index() would have an affect on the redirect, I think we can do without the condescending tone. Thanks
On Tuesday, March 20, 2012 3:22:36 AM UTC-4, AD7six wrote:
> On Tuesday, 20 March 2012 02:41:51 UTC+1, glevine wrote:
>> @thatsgreat2345 That was just a typo.
>> Commenting out the print statements in the change method has no effect. I >> never see the "in the index" print statement and the browser simply shows a >> blank page with a couple of warnings about changing the salt and cipherSeed.
> Read this aloud "You can not send output to the webpage and then > redirect."
Fair enough. My example was only to show that I was having trouble with reaching certain points in the code. I didn't want to write a lot of code for an example that didn't need to be overly complex to get the point across.
No that stackoverflow post is not me. As I said previously, I'm not actually debugging with the code that I wrote above. I just posted an extremely rudimentary and flawed example to see if there was something outside of common sense that I was missing. The code I'm debugging doesn't print anywhere inside the method where the redirect happens. What's in index() shouldn't have any affect. If you must know, I have nothing in my index() method at the moment. I just want to see the url change, which it's not.
> guys. if you want to crappy debug here, use DIE();
> die('before redirect');
> $this->redirect(array('controller' => 'test', 'action' => 'index'));
> die('after redirect'); // totally nonsense, because it will NEVER reach this point
> echo creates problems - and doesnt solve any!
> if you want to NOT crappy debug with redirects, use something else, like > log():
> $this->log('some log entry', 'test');
> and look into /tmp/logs/test.log
> Am Dienstag, 20. März 2012 11:23:29 UTC+1 schrieb pokerphp:
>> Also never do any output from the controller. If you still want to make >>>>>> it nasty use something like
>> public function index() { $nasty = 'in the index'; $this->set('nasty', $nasty); }
>> then in the View/Tests/index.ctp
>> <?php
>> print $nasty;
>> ?>
>> this will be way better than printing directly from the controller.
In case anyone really cares, it was failing because the debugger was outputting warnings about changing the salt and cipherSeed configs. So that was the output that was being printed before the redirect which was giving me issues. Obviously I should have just taken care to do that sooner, but I was being lazy and assuming that problem was with my code and not the CakePHP library. Live 'n' learn.
> In case anyone really cares, it was failing because the debugger was > outputting warnings about changing the salt and cipherSeed configs. So that > was the output that was being printed before the redirect which was giving > me issues. Obviously I should have just taken care to do that sooner, but I > was being lazy and assuming that problem was with my code and not the > CakePHP library. Live 'n' learn.
> On Sunday, March 18, 2012 10:28:02 PM UTC-4, glevine wrote:
>> I have the following code:
>> class TestsController extends AppController
>> {
>> public function index()
>> {
>> print 'in the index';
>> }
On Tuesday, 20 March 2012 18:15:44 UTC+1, glevine wrote:
> In case anyone really cares, it was failing because the debugger was > outputting warnings about changing the salt and cipherSeed configs.
The point of my message was to highlight that's the case - and that the first reply you received (2 hours after you posted originally) should also have led you to the same conclusion. As such, the rest of the thread is mostly noise.
Evidently though the meaning of my message was not understood, the intention was literally to get you to re-read that first reply.
I'm not actually debugging with the code that I wrote above.
It's a good idea to post slimmed down code, but it has to actually work unless it's a pseudo-code example. It's a really bad idea to post fundamentally wrong code that you aren't using and haven't tested - it will often, as is the case here, lead people to focus on problems with your example rather than the problem you're actually looking at.