CodeIgniter Forums
accessing a $_SESSION variable is failing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: accessing a $_SESSION variable is failing (/thread-76964.html)

Pages: 1 2


accessing a $_SESSION variable is failing - richb201 - 07-08-2020

I have a little code sitting in a php file that is in the assets directory. I know that is not normal, but this is where the vendor keeps it. When that code runs the line below is executed. 

$campaign=$this->$_SESSION['campaign'];

However,  $campaign yields null (as seen in the debugger). But when I look at it in the debugger, $_SESSION[campaign'] has the string "Apple" in it. How can I get the value of the $_SESSION into the variable $campaign?


RE: accessing a $_SESSION variable is failing - InsiteFX - 07-08-2020

Is the session started by you or the file in the assets vendor?

If the session is already started you should be able to get like below.

PHP Code:
$campaign $_SESSION[campaign']; 

try that.


RE: accessing a $_SESSION variable is failing - richb201 - 07-08-2020

That worked to load $campaign. I am having a problem with the query
->query("SELECT bus_comp FROM business_components WHERE campaign=$campaign AND email='[email protected]'")

I get :
An uncaught Exception was encountered
Type: Error
Message: Call to a member function execute() on boolean
Filename: /app/vendor/koolreport/core/src/datasources/MySQLDataSource.php
Line Number: 384


RE: accessing a $_SESSION variable is failing - richb201 - 07-08-2020

Solved. I needed to use '$campaign' in the query string.

Thx


RE: accessing a $_SESSION variable is failing - InsiteFX - 07-09-2020

If you using double quotes you can do it like this.

PHP Code:
{$campaign



RE: accessing a $_SESSION variable is failing - richb201 - 07-16-2020

I am trying to build a string to use in this cmd

$cmd = "soffice --convert-to png ".$inputFile." --outdir ". $ouputDirectory;

I tried using $inputFile="/app".{$field_info['upload_path']}; to build the input file name. But I get this error:

Error: Cannot use object of type stdClass as an array

$field_info is coming from the function:

function callback_after_upload2($uploader_response,$field_info, $files_to_upload){}


RE: accessing a $_SESSION variable is failing - InsiteFX - 07-16-2020

Try this and let me know if it works.

PHP Code:
$cmd "soffice --convert-to png {$inputFile} --outdir {$ouputDirectory}"



RE: accessing a $_SESSION variable is failing - richb201 - 07-16-2020

(07-16-2020, 07:54 AM)InsiteFX Wrote: Try this and let me know if it works.

PHP Code:
$cmd "soffice --convert-to png {$inputFile} --outdir {$ouputDirectory}"
The problem is getting the $inputFile.


$inputFile="/app".$field_info['upload_path'];

This is in a call back where $field_info is  a structure being passed to the callback. upload_path contains the full path to the file that was just uploaded. I need to add /app onto the front of it. But I can't seems to access $field_info['upload_path']. 



RE: accessing a $_SESSION variable is failing - InsiteFX - 07-16-2020

Can you do a var_dump of it?

PHP Code:
var_dump($field_info['upload_path']);
exit(); 



RE: accessing a $_SESSION variable is failing - richb201 - 07-16-2020

(07-16-2020, 11:17 AM)InsiteFX Wrote: Can you do a var_dump of it?

PHP Code:
var_dump($field_info['upload_path']);
exit(); 
I get the same error: cannot use object of type stdClass as array