• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Private vairable not working

#1
On the top above my __construct() area in my library I have a variable called $set_the_time_for_cookie_to_expire because the time() has brackets it is throwing error


Code:
A PHP Error was encountered

Severity: Parsing Error

Message: syntax error, unexpected '(', expecting ',' or ';'

Filename: libraries/Customer.php

Line Number: 6

Backtrace:


Is there any way to be able to use php time() like what I am after?


PHP Code:
private $customer_id;
private 
$set_the_time_for_cookie_to_expire time() + 20 60;
 
   
public function __construct() {
 
  $this->CI = &get_instance();
 
  $this->CI->load->library('session');

 
  if (!$this->CI->session->userdata('is_logged_in')) {
 
     $this->autologin();
 
  }


There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#2
Create a set and get method to set and get the cookie expire time.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Assign the value in the __construct method.

PHP Code:
private $set_the_time_for_cookie_to_expire;

public function 
__construct() {
   
$this->set_the_time_for_cookie_to_expire time() + 20 60;

Reply

#4
Yep that will work also but I would still create the set and get methods so that if you ever want to change the expiration time you can.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.