Tag: kohana

Kohana, PHP

How to configure cookies in Kohana

Put this in your bootstrap.php file: Kohana_Cookie::$salt = md5(’?jrA#VXrEH-f@?8!vuve6VCGgcjm#ar?BBAG’); //change it Kohana_Cookie::$expiration = 86400; //1 day Kohana_Cookie::$domain = ‘.mydomain.com’; Kohana_Cookie::$secure = TRUE; //allow cookies to be accessed only on a secure connection Kohana_Cookie::$httponly = TRUE; //make cookies inaccessible to JavascriptKohana_Cookie::$salt = md5(‘?jrA#VXrEH-f@?8!vuve6VCGgcjm#ar?BBAG’); //change it Kohana_Cookie::$expiration = 86400; //1 day Kohana_Cookie::$domain = ‘.mydomain.com’; Kohana_Cookie::$secure = TRUE; …

Kohana, PHP

How to avoid repeating code to check if a user is logged in

First of all create your own Controller that all other controllers will inherit from. Name it Mycontroller, for example: defined(’SYSPATH’) or die(’No direct script access.’);   class Controller_Mycontroller extends Controller {   public function before() { parent::before(); //…. }   } // Enddefined(‘SYSPATH’) or die(‘No direct script access.’); class Controller_Mycontroller extends Controller { public function …

Frameworks, Kohana, PHP

Kohana Internationalization

Kohana has a fairly simple and easy to use i18n system. Kohana has a __() function to do your translations for you. This function is only meant for small sections of text, not entire paragraphs or pages of translated text. To echo a translated string: echo __(’username’);echo __(‘username’); To change the displayed language: I18n::lang(’en’);I18n::lang(‘en’); To …

Databases, Frameworks, Kohana, MySQL, SQL

Kohana MySQL Database Schema

Kohana 3.3 MySQL Database Schema github CREATE TABLE IF NOT EXISTS `roles` ( `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(32) NOT NULL, `description` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uniq_name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;   INSERT INTO `roles` (`id`, `name`, `description`) VALUES(1, ‘login’, ‘Login privileges, granted after account confirmation’); INSERT INTO …