the other. I can't figure out why. I am using CakePHP 1.2.5.
//
//Does work
//
sessions_controller.php:
class SessionsController extends AppController {
var $name = "Sessions";
var $layout = "ajax";
var $uses = array();
function create(){
if($this->Session->read('Data') == null){
$this->Session->write('Data', rand());
}
$this->set('data', $this->Session->read('Data'));
$this->set('SessionID', $this->Session->id());
}
}
create.ctp:
$msgJson["SessionID"] = $SessionID;
$msgJson["data"] = $data;
echo json_encode($msgJson);
//results in ({"SessionID":"sd8s8o32edmjnjt94ouse99fd2","data":19409})
every time (parenthesis not in result)
//
//Doesn't Work
//
messages_controller.php:
class MessagesController extends AppController {
var $name = 'Messages';
var $layout = "ajax";
function listMessages() {
if($this->Session->read('Data') == null){
$this->Session->write('Data', rand());
}
$this->set('data', $this->Session->read('Data'));
$this->set('SessionID', $this->Session->id());
$this->set('messages', $this->Message->find("all",
array("order"=>"priority ASC")));
}
}
list_messages.ctp:
$msgJson["count"] = count($messages);
$msgJson["SessionID"] = $SessionID;
$msgJson["SessionData"] = $data;
foreach($messages as $message){
$msg[] = $message["Message"];
}
$msgJson["items"] = $msg;
echo json_encode($msgJson);
/*
results in ({"count":3,"SessionID":"","SessionData":27384,"items":
[{"id":"4","priority":"3","subject":"Another
message","message":"adsfasdf"},
{"id":"2","priority":"3","subject":"testing again","message":"just
seeing ow "},
{"id":"7","priority":"3","subject":"asdgasdg","message":"asdfasdfasd"}]})
except the SessionData changes everytime and the SessionID never shows
up.
*/
Any ideas what might be wrong?
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
No comments:
Post a Comment