Hi,
I'm new to php and Cake, and I appreciate the fine work that has gone
in to making Cake what it is. So far I have been able to figure out
what I've needed from the manual, group, and googling, but I haven't
figured this one out.
When I try to write to the session, I do not get any session variables
recognized or assigned. I am probably overlooking something simple!
I'm using cake 1.2.0.6311 beta, MySql, php5 and apache2 on localhost
for development.
In php.ini, I have set session.auto_start = 0
In core.php I have:
Configure::write('Session.save', 'cake')-- my temp directory is
writable by the server as the session file is written but it is
empty.
Configure::write('Session.cookie', 'CAKEPHP')--the cookie is written.
Configure::write('Session.start', true);
Configure::write('Session.timeout', '120');
security is at medium.
I declared the Session in both the helper and component arrays.
I have been trying to implement an md5 login; I originally wanted to
write my token to the session and then use it in my test on form
submission, but I couldn't figure that out properly, so now I am
returning the token with the post data (not the best solution, I don't
expect) Neither of the $this->Session->write statements below give me
results. The getRandomString() function is in my model, and
$challenge is the value of token when I set up the form in the login
view. (I also have md5 javascript on the client side.) I was also
getting a config doesn't exist error in the session earlier, but that
doesn't come with the code as it is now.
Below is the code from my controller and the session component array.
Thanks for your time.
My controller login:
function login()
{
if (empty($this->data))
{
$randomstring = $this->User->getRandomString();
$this->Session->write('Users.challenge',$randomstring);//this
didn't work but I have it here so you can see //what I was trying to
do
$this->set('challenge',$randomstring);
}
if (!empty($this->data))
{
//find the user in the database and test the password
$someone = $this->User->findByUsername($this->data['User']
['username']);
if(!empty($someone['User']['password']) &&
md5($someone['User']['password'].$this->data['User']['token']) ==
$this->data['User']['password'])
{
$this->Session->write('Users.user', $someone['User']);//
This doesn't work either.
$this->Session->setFlash('You have successfully logged
in.');
$this->redirect(array('controller'=> 'ads', 'action'=>
'newAd'));
//exit();
}
else
{
$this->Session->setFlash('Sorry, your login was not
successful.');
$this->redirect(array('controller'=>'users',
'action'=>'login'));
exit();
}
}
}
Here is the Session object after a successful login
[Session] => SessionComponent Object
(
[__active] => 1
[__started] => 1
[__bare] => 0
[valid] => 1
[error] =>
[_userAgent] => 9ed5f7e31bfafe7b4aa4dadf9c63b47c
[path] => /
[lastError] =>
[security] => medium
[time] => 1207957286
[sessionTime] => 1207969286
[watchKeys] => Array
(
)
[id] =>
[_log] =>
[host] => localhost
[cookieLifeTime] => 604800
)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---