I'm having the same problem!!! It simply won't save sessions for me.
On Apr 14, 1:49 pm, columbus <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am a beginner in both php andcakePHP. I have met the same problem
> as many previous posts. However, I have tried most of the solutions
> and it is still not working.
>
> I was just following the IBM Tutorial "Cook up Web sites fast withCakePHP" to
> learn how to write the script for login. However, after
> seccessfully login, thesessioninformation such as $_SESSION['user']
> were not saved if I use the redirect() function. To sovle the problem,
> I modified my code so that it will redirect to the same login page and
> echosessionvariables andsessionid.
> After redirection, thesessionvariables are missing and thesession
> id is always the same. If I comment these two lines
> "$this->redirect('/users/login');
> $this->exit();"
> I can see the correctsessionvariables and the samesessionid. That
> means they were saved.
> My question is that is it possible to keep thesessionvariables after
> redirect to other pages without configurate Apache server since it is
> in the university.
>
> The code is as following, and my system is WinXP
> +Apache2.0.59+MySQL5.0.45+PHP4.4.7+cakePHP1.1.19.6305.
> Here are the methods I have already tried and did not work.
> 1.set the security level in core.php to low.
> 2.apply function exit();
> 3.I tried to comment out the lines as Grant Cox mentioned in thesession.php.
>
> In users_controller.php
>
> function login()
> {
> $this->set('error', false);
> if ($this->data)
> {
> $results = $this->User->findByUsername($this->data['User']
> ['username']);
> if ($results && $results['User']['password']
> ==md5($this->data['User']['password']))
>
> {
> $this->Session->write('username',$this->data['User']
> ['username']);
> $results['User']['last_login'] = date("Y-m-d H:i:s");
> $this->Session->write('last_login',$results['User']
> ['last_login']);
> $this->redirect('/users/login');
> $this->exit();
> }
> else
> {
> $this->set('error', true);
> }
> }
> }
>
> In login.thtml
> <?php
> var_dump($_SESSION);
> echo ("<br>sessionid is ".session_id());
> if ($error)
> {
> e('InvalidLogin.<br>');
> }
> ?>
> Please log in.
> </p>
> <?php echo $html->formTag('/users/login')?>
> <label>Username:</label>
> <?php echo $html->inputTag('User/username', array('size' => '40')) ?>
> <label>Password:</label>
> <?php echo $html->password('User/password', array('size' => '20')) ?>
> <?php echo $html->submitTag('Login') ?>
> </form>
> <?php echo $html->link('register', '/users/register') ?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---