Title: set session with delay
Last modified: August 30, 2016

---

# set session with delay

 *  [alichimeh](https://wordpress.org/support/users/alichimeh/)
 * (@alichimeh)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/set-session-with-delay/)
 * Hi
    for creating a cart plugin I need to use widget. widget code area is in other
   file that has been connected with required_once to main page. but when I click
   to add cart for increasing amount of goods, the counter in widget area count 
   number of goods after two click although SESSION is two. here is sample of widget
   page.
 *     ```
       class product_widget extends WP_Widget
       {
       	public function __construct()
       	{
       		$option=array('description'=>'نمایش سبد خرید ,دکمه ثبت خرید و خالی کردن سبد خرید');
               parent::__construct('wp_product','shop : سبد خرید',$option);
       	}
       	public function widget($args,$instance)
       	{
       		var_dump($_SESSION['cart']);
       		//unset($_SESSION['cart']);
       	}
       	public function form($instance)
       	{
   
       	}
       	public function update($new_instance,$old_instance)
       	{
   
       	}
       }
       ```
   
 * it’s sounds good that when I use var_dump for session in main plugin page it’s
   correct

The topic ‘set session with delay’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [session](https://wordpress.org/support/topic-tag/session/)

 * 0 replies
 * 1 participant
 * Last reply from: [alichimeh](https://wordpress.org/support/users/alichimeh/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/set-session-with-delay/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
