|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Recursion Problem
first of all am using CakePhp but i dont think it matters anyway
on the index page am checking for the session but am having a redirection problem when my function checks for the session and redirects here is the code <?php $log = 0; $flag = 0 ; function index(){ if($flag == 0) $this->checkSession(); } function checkSession() { if (!$this->Session->check('User')) { $log = 0; $flag = 1; $this->redirect('/helps/'); exit(); } else $log = 1; $flag = 0; } ?> |
|
#2
|
||||
|
||||
|
I don't know anything about CakePHP, but looking at your code $flag is not a global variable, and is lost inside the scope of the function. You either need to pass $flag as an argument, create a constant which is global, or use "global $flag;" in your function so $flag is now available in the function scope. If none of these work, I cannot comment further if CakePHP changes the way PHP normally works!
-jim |
|
#3
|
||||
|
||||
|
And can you use forum code tags when posting, it makes reading code easier for the people who are going to help you.
AND!!! Like I say to everyone using a helper or framework, go to the vendors site, your going to get your answer quicker. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|