PHP Session Variable - Property access is not allowed yet - session-variables

I have the following code at the top of my index.php:
<?php
session_start();
require 'includes/db_connect.php';
if(!isset($_SESSION['conn'])){
$_SESSION['conn'] = db_connect('igslogistics01');
}
var_dump($_SESSION);
?>
The result of the output is:
Warning: var_dump(): Property access is not allowed yet
I have seen similar questions asked, related mainly to db connections but as you can see in my case I can't access any of the session variable.
The server is running PHP v 7.1.0
Any suggestions or pointers would be appreciated.

Related

Google Apps Script ScriptDb permissions issue

I am having an issue trying to query the ScriptDb of a resource file in Google Apps Script. I create a script file (file1), add it as a resource to another script file (file2). I call file1 from file2 to return a handle to its ScriptDb. This works fine. I then try to query the ScriptDb but have a permissions error returned.
Both files owned by same user and in same google environment
See code below:
file 1:
function getMyDb() {
return ScriptDb.getMyDb;
}
file 2 (references file1):
function getDataFromFile1() {
var db = file1.getMyDb(); // This works
var result = db.query({..............}); // This results in a permissions error!
}
I am at a loss to understand why I can access file1 and get back a handle on the ScriptDb, but then am not able to query it, due to an permissions issue.
I have tried to force file1 to require re-authorization, but have not yet been successful. I tried adding a new function and running it, so any suggestions there would be gratefully received.
Thanks in advance
Chris
There appears to be an error in file1/line2. It says "return ScriptDb.getMyDb;" but it should say "return ScriptDb.getMyDb();"
If you leave out the ()s then when you call file1 as a library, file1.getMyDb() will return a function which you store in var db. Then the line var result = db.query({..............}) results in an error because there is no method "query" in the function.
Is that what's causing your error?
I have figured out what the problem was, a misunderstanding on my part regarding authorisation. I was thinking of it in terms of file permissions, when in fact that problem was that my code was not authorised to run the DbScript service. As my code calls a different file and receives back a pointer to a ScriptDb database it is not using the ScriptDb service, so then when it calls the db.query() it invokes the ScriptDb service, for which it is not authorised.
To resolve this I just had to create a dummy function and make a ScriptDb.getMyDb() call, which triggered authorisation for the service. The code then worked fine.
Thanks for the input though.
Chris

Yii: APC Cache throwing error of Servers not being configured

I have configured APC Cache for YII application but when I put a variable in cache, I get the following error for line 222:
APC Cache Error
http://i.stack.imgur.com/qu2tI.jpg
Following is my config/main.php entry for APC Cache:
'cache'=>array(
'class'=>'system.caching.CApcCache',
'servers'=>array(
array('host'=>'localhost','port'=>11211,'weight'=>60),
array('host'=>'localhost','port'=>11212,'weight'=>40),
),
),
Following is the code that I use to put data in cache:
public function getReligion(){
$lstofvals=Yii::app()->cache->get('RELIGION');
if ($lstofvals===false){
Yii::log('Loading Religion Data from List of Values.');
$lstofvals=$this->PopulateLSTValsData('RELIGION');
Yii::app()->cache->set('RELIGION', $lstofvals);
}
return $lstofvals;
}
I can see the output of apc.php in form of graphs and all other details.
Any help would much appreciated.
Please also confirm if my strategy to store the base data in cache is correct. I am new to Yii and found out about MemCache and APC Cache to be good candidates for such requirements.
Many thanks,
Faisal
Remove the entire servers array from your config file. APC isnt distributed. Servers are used for memcache as far as I know

yii logs differ - where should we look at?

We are developing using Yii. One user sees warnings trow by Yii, the other user don't.
We have the same app/config.php file.
Could this be apache related ?
Where should we look at for more diferences in order to make them see the same logs ?
index.php and .htaccess are equal on all machines (they under git btw);
The code that we had and that was returning an error that only some users were seeing and others don't is the following:
1 $(document).ready(function(){
2 if('<?php echo Yii::app()->controller->action->id?>' == 'update'){
3 if('<?php echo Yii::app()->user->id;?>' != '<?php echo $model->createUser->id; ?>'){
and the error is:
trying to access property of a non-object
(on line 3).
This error is SOLVED. It's the fact that only some developers sees this and others don't that troubles me.
Please advice

Undefined variable SESSION

I am using php $_SESSION like this
$_SESSION['original_referrer_location']
but i keep getting this error
Notice: Undefined variable: _SESSION in /var/www/m/inc/referrer.php on line 3
so I added this to the top of my script
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
session_set_cookie_params(0, '/');
session_start();
and all is good.
Is there a way to turn on sessions for good because having to add this on top of any script that needs a session is kind of redundant....i went to php.ini but there are many calls that start with session...any ideas on what i need to change ...I am on ubuntu 10.10/php5 in case that matters
There is:
http://www.php.net/manual/en/session.configuration.php#ini.session.auto-start
But i wouldn't recommend using it. For example you would like to store whole object in session, to do it you would need to include file with class declaration first, otherwise unserialized object will be of incomplete class.
Other way is to auto-prepend file that sets some basic configuration and starts session
Yes
session.auto.start
session.auto_start boolean session.auto_start specifies whether the session module starts a session automatically on request startup.
Defaults to 0 (disabled).
When you want to use sessions, remember to call session_start() before the HTML tag
<?php session_start(); ?>
<html>
<body>
...

Asterisk with new functions

I created a write func odbc list records files in sql table:
[R]
dsn=connector
write=INSERT INTO ast_records (filename,caller,callee,dtime) VALUES
('${ARG1}','${ARG2}','${ARG3}','${ARG4}')
prefix=M
and set it in dialplan :
exten => _0X.,n,Set(
M_R(${MIXMONITOR_FILENAME}\,${CUSER}\,${EXTEN}\,${DTIME})= )
when I excute it I get an error : ast_func_write: M_R Function not registered:
note that : asterisk with windows
First thing I saw was you were performing the call to the function incorrectly...you need to be assigning values, not arguments....try this:
func_odbc.conf:
[R]
dsn=connector
prefix=M
writesql=INSERT INTO ast_records (filename,caller,callee,dtime) VALUES('${VAL1}','${VAL2}','${VAL3}','${VAL4}');
dialplan:
exten => _0X.,1,Set(M_R()=${MIXMONITOR_FILENAME}\,${CUSER}\,${EXTEN}\,${DTIME})
If that doesn't help you, continue on in my list :)
Make sure func_odbc.so is being loaded by Asterisk. (from the asterisk CLI: module show like func_odbc)... If it's not loaded, it can't "build" your custom odbc query function.
Make sure your DSN is configured in /etc/odbc.ini
Make sure that /etc/asterisk/res_odbc.conf is properly configured
Make sure you're calling the DSN by the right name (I see it happen all the time)
enable verbose and debug in your Asterisk logging, do a logger reload, core set verbose 5, core set debug 5, and then try the call again. when the call finishes, review the log, you'll see much more output regarding what happened...
Regarding the answer from recluze...Not to call you out here, but using a PHP AGI is serious overkill here. The func_odbc function works just fine, why create more overhead and potential security issues by calling an external script (which has to use a interpreter program on TOP itself)?
you should call func odbc function as "ODBC_connector". connector should be use in the func_odbc.conf file [connector]. In the dialplan it should call like this.
exten=> _0x.,n,ODBC_connector(${arg1},${arg2})
I don't really understand the syntax you're trying to use but how about using AGI (with php) for this. Just define your logic in a php script and call it from your dialplan as:
exten => _0X.,n,AGI(script-filename.php,${CUSER},${EXTEN},${DTIME})