![]() |
|
Snippets |
|
Here is the schema you need to set up database session storage.
CREATE TABLE `session` ( `sess_id` varchar(32) NOT NULL, `sess_data` text NOT NULL, `sess_time` int(11) NOT NULL );
<?php class mySessionStorage extends sfMySQLSessionStorage { public function initialize ($context, $parameters = null) { session_set_cookie_params ( 90*24*3600 , "/", ".domain.tld" ); parent::initialize($context, $parameters); } } ?>
Then you have to put in factories.yml
all:
storage:
class: mySessionStorage
param:
database: ...
db_table: session
db_id_col: sess_id
db_data_col: sess_data
db_time_col: sess_time
session_name: ...
Here is a little hack to use http auth when credentials or auth is insufficient:
public function executeSecure() { if (!$this->getUser()->hasAttribute("secure_referer")) $this->getUser()->setAttribute("secure_referer", $this->getRequest()->getReferer()); if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Member Area"'); header('HTTP/1.0 401 Unauthorized'); return sfView::NONE; } else { if ($this->getUser()->tryLogin($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])) { return $this->redirect($this->getUser()->getAttribute("secure_referer")); } else { header('WWW-Authenticate: Basic realm="Member Area"'); header('HTTP/1.0 401 Unauthorized'); return sfView::NONE; } } }
No template is needed, as everytime you access it will redirect to the referer. Then change in app/yourapp/config/settings.yml the secure_module and secure_action to match this module.
You will need a myUser::tryLogin function that returns a boolean saying "auth is ok" or "bad auth"
And then you're done :p
[from my Wiki Post ab out that]
More a PHP trick than symfony's one, but as you can't with propel randomize order of results, just do:
$c = new Criteria() ... fill your criteria there ... $result = MyTablePeer::doSelect($c); shuffle($result);
obvious? sorry, seen someone asking on IRC once :D