On 16-Jan-2007, at 10:10, Flexewebs wrote:


Hi guys,

How do I print a session variable in a view please?

I am using the following code in the controller to write a session
variable.

$this->Session->write('mailcode', $_POST["mailcode"]);

I am wanting to specifically use the session variable within my view if
at all possible.


Set it as a view variable as well. The Session is for passing data between requests, View vars are for passing data to the View.

$this->set('mailcode', $_POST["mailcode"]);

Also, pulling things straight out of $_POST is always a bad idea. For one thing Cake has already pulled it out for you (into $this->params) and, for another, you are tossing raw input around without validating or sanitizing it...

s.

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to