本文整理匯總了PHP中CI::session方法的典型用法代碼示例。如果您正苦於以下問題:PHP CI::session方法的具體用法?PHP CI::session怎麽用?PHP CI::session使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CI
的用法示例。
在下文中一共展示了CI::session方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: logout
public function logout()
{
\CI::auth()->logout();
//when someone logs out, automatically redirect them to the login page.
\CI::session()->set_flashdata('message', lang('message_logged_out'));
redirect('admin/login');
}
示例2: index
public function index($slug)
{
$product = \CI::Products()->slug($slug);
if (!$product) {
throw_404();
} else {
$product->images = json_decode($product->images, true);
if ($product->images) {
$product->images = array_values($product->images);
} else {
$product->images = [];
}
//set product options
$data['options'] = \CI::ProductOptions()->getProductOptions($product->id);
$data['posted_options'] = \CI::session()->flashdata('option_values');
//get related items
$data['related'] = $product->related_products;
//create view variable
$data['page_title'] = $product->name;
$data['meta'] = $product->meta;
$data['seo_title'] = !empty($product->seo_title) ? $product->seo_title : $product->name;
$data['product'] = $product;
//load the view
$this->view('product', $data);
}
}
示例3: delete
public function delete($direction = false, $id = false)
{
if ($id) {
\CI::db()->delete($this->_db_table[$direction], array('id' => $id));
} else {
//if they do not provide an id send them to the product list page with an error
\CI::session()->set_flashdata('error', lang('error_not_found'));
}
redirect('admin/materials/' . $direction);
}
示例4: completeSitemap
public function completeSitemap()
{
$xml = $this->partial('sitemap_xml_foot', [], true);
echo $xml;
$file = fopen('sitemap.xml', 'a');
fwrite($file, $xml);
fclose($file);
\CI::session()->set_flashdata('message', lang('success_sitemap_generate') . ' File location ' . site_url('sitemap.xml'));
redirect('admin/sitemap');
}
示例5: forgotPassword
public function forgotPassword()
{
$data['page_title'] = lang('forgot_password');
$submitted = \CI::input()->post('submitted');
\CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', ['email_callable', function ($str) {
$reset = \CI::Customers()->reset_password($str);
if (!$reset) {
\CI::form_validation()->set_message('email_callable', lang('error_no_account_record'));
return FALSE;
} else {
//user does exist. and the password is reset.
return TRUE;
}
}]]);
if (\CI::form_validation()->run() == FALSE) {
$this->view('forgot_password', $data);
} else {
\CI::session()->set_flashdata('message', lang('message_new_password'));
redirect('login');
}
}
示例6: delete
public function delete($id = false)
{
if ($id) {
$product = \CI::Products()->find($id);
//if the product does not exist, redirect them to the customer list with an error
if (!$product) {
\CI::session()->set_flashdata('error', lang('error_not_found'));
redirect('admin/products');
} else {
//if the product is legit, delete them
\CI::Products()->delete_product($id);
\CI::session()->set_flashdata('message', lang('message_deleted_product'));
redirect('admin/products');
}
} else {
//if they do not provide an id send them to the product list page with an error
\CI::session()->set_flashdata('error', lang('error_not_found'));
redirect('admin/products');
}
}
示例7: delete
function delete($id)
{
$category = \CI::Categories()->find($id);
//if the category does not exist, redirect them to the customer list with an error
if ($category) {
\CI::Categories()->delete($id);
\CI::session()->set_flashdata('message', lang('message_delete_category'));
redirect('admin/categories');
} else {
\CI::session()->set_flashdata('error', lang('error_not_found'));
}
}
示例8: delete
function delete($id)
{
$page = \CI::Pages()->get_page($id);
if ($page) {
\CI::Pages()->delete_page($id);
\CI::session()->set_flashdata('message', lang('message_deleted_page'));
} else {
\CI::session()->set_flashdata('error', lang('error_page_not_found'));
}
redirect('admin/pages');
}
示例9: delete_message
public function delete_message($id)
{
\CI::Messages()->delete_message($id);
\CI::session()->set_flashdata('message', lang('message_deleted_message'));
redirect('admin/settings/canned_messages');
}
示例10: zone_area_form
public function zone_area_form($zone_id, $area_id = false)
{
\CI::load()->helper('form');
\CI::load()->library('form_validation');
\CI::form_validation()->set_error_delimiters('<div class="error">', '</div>');
$zone = \CI::Locations()->get_zone($zone_id);
$data['zone'] = $zone;
//default values are empty if the product is new
$data['id'] = '';
$data['code'] = '';
$data['zone_id'] = $zone_id;
$data['tax'] = 0;
if ($area_id) {
$area = (array) \CI::Locations()->get_zone_area($area_id);
//if the country does not exist, redirect them to the country list with an error
if (!$area) {
\CI::session()->set_flashdata('error', lang('error_zone_area_not_found'));
redirect('admin/locations/zone_areas/' . $zone_id);
}
$data = array_merge($data, $area);
}
\CI::form_validation()->set_rules('code', 'lang:code', 'trim|required');
\CI::form_validation()->set_rules('tax', 'lang:tax', 'trim|numeric');
if (\CI::form_validation()->run() == FALSE) {
$this->view('country_zone_area_form', $data);
} else {
$save['id'] = $area_id;
$save['zone_id'] = $zone_id;
$save['code'] = \CI::input()->post('code');
$save['tax'] = \CI::input()->post('tax');
\CI::Locations()->save_zone_area($save);
\CI::session()->set_flashdata('message', lang('message_saved_zone_area'));
//go back to the product list
redirect('admin/locations/zone_areas/' . $save['zone_id']);
}
}
示例11: delete
public function delete($id = false)
{
if ($id) {
$coupon = \CI::Coupons()->getCoupon($id);
//if the promo does not exist, redirect them to the customer list with an error
if (!$coupon) {
\CI::session()->set_flashdata('error', lang('error_not_found'));
redirect('admin/coupons');
} else {
\CI::Coupons()->deleteCoupon($id);
\CI::session()->set_flashdata('message', lang('message_coupon_deleted'));
redirect('admin/coupons');
}
} else {
//if they do not provide an id send them to the promo list page with an error
\CI::session()->set_flashdata('message', lang('error_not_found'));
redirect('admin/coupons');
}
}
示例12:
</li>
</ul>
</div>
</div>
</nav>
<?php
}
?>
<div class="container">
<?php
//lets have the flashdata overright "$message" if it exists
if (CI::session()->flashdata('message')) {
$message = CI::session()->flashdata('message');
}
if (CI::session()->flashdata('error')) {
$error = CI::session()->flashdata('error');
}
if (function_exists('validation_errors') && validation_errors() != '') {
$error = validation_errors();
}
?>
<div id="js_error_container" class="alert alert-error" style="display:none;">
<p id="js_error"></p>
</div>
<div id="js_note_container" class="alert alert-note" style="display:none;">
</div>
<?php
示例13: echo
<br class="clear">
<div class="productDetails">
<div class="productExcerpt">
<?php
echo (new content_filter($product->excerpt))->display();
?>
</div>
<?php
echo form_open('cart/add-to-cart', 'id="add-to-cart"');
?>
<input type="hidden" name="cartkey" value="<?php
echo CI::session()->flashdata('cartkey');
?>
" />
<input type="hidden" name="id" value="<?php
echo $product->id;
?>
"/>
<?php
if (count($options) > 0) {
?>
<?php
foreach ($options as $option) {
$required = '';
if ($option->required) {
$required = ' class="required"';
示例14: remove_compare
function remove_compare($type)
{
$url[] = $_POST['url'];
$compare = \CI::session()->userdata('compare');
$compare = array_diff($compare, $url);
\CI::session()->set_userdata('compare', $compare);
//print_r( $compare );
if (count($compare) > 0) {
echo true;
}
exit;
}
示例15: createGuest
private function createGuest()
{
//create a temp customer
$customerID = CI::Customers()->createGuest();
$customer = CI::db()->where('id', $customerID)->get('customers')->row();
CI::session()->set_userdata('customer', $customer);
}