public function create_cart() { // Generate hash of new cart for cookie $hash = sha1(microtime() . Text::random()); // Save cart into database $this->_cart_id = Arr::get(DB::insert('carts', array('hash', 'created_at'))->values(array($hash, time()))->execute(), 0); // Save cart to cookie Cookie::set('cart', $hash, 60 * 60 * 24 * 365); return true; }
/** * Generate a random password */ public static function generate_random_password() { return Text::random('alnum', 8); }