Subversion Repositories SmartDukaan

Rev

Rev 16270 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16270 Rev 16276
Line 175... Line 175...
175
 
175
 
176
		// Unserialize the session array
176
		// Unserialize the session array
177
		$session = $this->_unserialize($session);
177
		$session = $this->_unserialize($session);
178
 
178
 
179
		// Is the session data we unserialized an array with the correct format?
179
		// Is the session data we unserialized an array with the correct format?
180
		if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['last_activity']))
180
		if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity']))
181
		{
181
		{
182
			$this->sess_destroy();
182
			// $this->sess_destroy();
183
			return FALSE;
183
			// return FALSE;
184
		}
184
		}
185
 
185
 
186
		// Is the session current?
186
		// Is the session current?
187
		if (($session['last_activity'] + $this->sess_expiration) < $this->now)
187
		if (($session['last_activity'] + $this->sess_expiration) < $this->now)
188
		{
188
		{
189
			$this->sess_destroy();
189
			// $this->sess_destroy();
190
			return FALSE;
190
			// return FALSE;
191
		}
191
		}
192
 
192
 
193
		// Does the IP match?
193
		// Does the IP match?
194
		if ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address())
194
		if ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address())
195
		{
195
		{
196
			$this->sess_destroy();
196
			// $this->sess_destroy();
197
			return FALSE;
197
			// return FALSE;
198
		}
198
		}
199
 
199
 
200
		// Does the User Agent Match?
200
		// Does the User Agent Match?
201
		/*if ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120)))
201
		if ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120)))
202
		{
202
		{
203
			// $this->sess_destroy();
203
			// $this->sess_destroy();
204
			// return FALSE;
204
			// return FALSE;
205
		}*/
205
		}
206
 
206
 
207
		// Is there a corresponding session in the DB?
207
		// Is there a corresponding session in the DB?
208
		if ($this->sess_use_database === TRUE)
208
		if ($this->sess_use_database === TRUE)
209
		{
209
		{
210
			$this->CI->db->where('session_id', $session['session_id']);
210
			$this->CI->db->where('session_id', $session['session_id']);
Line 322... Line 322...
322
		$sessid .= $this->CI->input->ip_address();
322
		$sessid .= $this->CI->input->ip_address();
323
 
323
 
324
		$this->userdata = array(
324
		$this->userdata = array(
325
					'session_id'	=> md5(uniqid($sessid, TRUE)),
325
					'session_id'	=> md5(uniqid($sessid, TRUE)),
326
					'ip_address'	=> $this->CI->input->ip_address(),
326
					'ip_address'	=> $this->CI->input->ip_address(),
327
					//'user_agent'	=> substr($this->CI->input->user_agent(), 0, 120),
327
					'user_agent'	=> substr($this->CI->input->user_agent(), 0, 120),
328
					'last_activity'	=> $this->now,
328
					'last_activity'	=> $this->now,
329
					'user_data'	=> ''
329
					'user_data'	=> ''
330
				);
330
				);
331
 
331
 
332
		// Save the data to the DB if needed
332
		// Save the data to the DB if needed
Line 334... Line 334...
334
		{
334
		{
335
			$this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata));
335
			$this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata));
336
		}
336
		}
337
 
337
 
338
		// Write the cookie
338
		// Write the cookie
339
		//$this->_set_cookie();
339
		$this->_set_cookie();
340
	}
340
	}
341
 
341
 
342
	// --------------------------------------------------------------------
342
	// --------------------------------------------------------------------
343
 
343
 
344
	/**
344
	/**
Line 381... Line 381...
381
				$this->CI->db->query($this->CI->db->update_string($this->sess_table_name,
381
				$this->CI->db->query($this->CI->db->update_string($this->sess_table_name,
382
											array('last_activity' => $this->userdata['last_activity']),
382
											array('last_activity' => $this->userdata['last_activity']),
383
											array('session_id' => $this->userdata['session_id'])));
383
											array('session_id' => $this->userdata['session_id'])));
384
			}
384
			}
385
 
385
 
386
			//return $this->_set_cookie($cookie_data);
386
			return $this->_set_cookie($cookie_data);
387
		}
387
		}
388
 
388
 
389
		// Save the old session id so we know which record to
389
		// Save the old session id so we know which record to
390
		// update in the database if we need it
390
		// update in the database if we need it
391
		$old_sessid = $this->userdata['session_id'];
391
		$old_sessid = $this->userdata['session_id'];
Line 415... Line 415...
415
 
415
 
416
			$this->CI->db->query($this->CI->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid)));
416
			$this->CI->db->query($this->CI->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid)));
417
		}
417
		}
418
 
418
 
419
		// Write the cookie
419
		// Write the cookie
420
		//$this->_set_cookie($cookie_data);
420
		$this->_set_cookie($cookie_data);
421
	}
421
	}
422
 
422
 
423
	// --------------------------------------------------------------------
423
	// --------------------------------------------------------------------
424
 
424
 
425
	/**
425
	/**
Line 494... Line 494...
494
			{
494
			{
495
				$this->userdata[$key] = $val;
495
				$this->userdata[$key] = $val;
496
			}
496
			}
497
		}
497
		}
498
 
498
 
499
		//$this->sess_write();
499
		$this->sess_write();
500
	}
500
	}
501
 
501
 
502
	// --------------------------------------------------------------------
502
	// --------------------------------------------------------------------
503
 
503
 
504
	/**
504
	/**
Line 519... Line 519...
519
			{
519
			{
520
				unset($this->userdata[$key]);
520
				unset($this->userdata[$key]);
521
			}
521
			}
522
		}
522
		}
523
 
523
 
524
		//$this->sess_write();
524
		$this->sess_write();
525
	}
525
	}
526
 
526
 
527
	// ------------------------------------------------------------------------
527
	// ------------------------------------------------------------------------
528
 
528
 
529
	/**
529
	/**
Line 674... Line 674...
674
				$expire,
674
				$expire,
675
				$this->cookie_path,
675
				$this->cookie_path,
676
				$this->cookie_domain,
676
				$this->cookie_domain,
677
				$this->cookie_secure
677
				$this->cookie_secure
678
			);
678
			);
679
		if (strlen($cookie_data)>3000){
-
 
680
			log_message("error", "length of cookie is ".strlen($cookie_data));
-
 
681
		}
-
 
682
	}
679
	}
683
 
680
 
684
	// --------------------------------------------------------------------
681
	// --------------------------------------------------------------------
685
 
682
 
686
	/**
683
	/**