CakePHP 2.3 cookies and Django 1.4 password reset
CakePHP 2.3 cookies
Will read a cookie called 'data'. Fairly simple.
This will check if a cookie exists. Useful.
this->Cookie->name = 'data'; $this->Cookie->time = 300; $this->Cookie->path = '/'; $this->Cookie->domain = '127.0.0.1'; $this->Cookie->key = 'data';
This is pretty self explanatory. It creates cookie attributes. What eludes me is the fact that I don't remember if the time is in seconds or milliseconds? I'd bet it's the first one. Now, to actually write that cookie:
$this->Cookie->write('data', 'true', false, 3600)
The first attribute is the key to use, the second the value, the third decided whether the cookie is encrypted (using cake's config.php salt), the last value is the expiry. I guess it's in seconds. What a relief.
//get the right date format for cookie //note how getTime() uses milliseconds instead of seconds var date = new Date(); date.setTime(date.getTime()+3600000); expires = 'expires=' + date.toGMTString() + ';'; document.cookie = 'CookieName[key]=value;' + expires + 'path=/;';
Django Password Reset
When using Heroku, use the run command with the --app parameter to invoke a manage.py command like so:
heroku run --app appName python manage.py changepassword admin
Gotta look into Heroku's manual and check how to specify an app so as to ignore using --app every single time.
And that's all folks!