Error - Element X is Undefined in Session - session

Getting this Error
ELEMENT CURRLANGUAGE IS UNDEFINED IN SESSION.
Don't understand why. It was working fine until yesterday
<cfif session.currLanguage eq 'English'>
<cfset session.currLanguage = ''>
</cfif>

Because currLanguage is not defined in the session scope. Womp Womp.
Try this to see what IS defined.
<cfdump var="#SESSION#">
It could be that something is not being set when it should. We'd have to see your code to tell for sure. If you think it's working okay and want to prevent unnecessary error messages in the future, you can do a check like this:
<cfif structKeyExists(SESSION, "currLanguage") AND SESSION.currLanguage is "English">
Logic Logic Logic
</cfif>

Please confirm those too
Please check the value update in the session scope properly.
The session scope will be created based on application name. so if we created the application name as dynamic or updated recently then the session scope will be created as new

Related

Codeigniter 4 how to unset session

I am trying to unset user session and set user session back again after use update their profile. I keep facing issue trying to unset the user session, I keep getting errors.
I have no issue setting my session like this :
session()->set($data);
But if I unset my session like this :
session()->unset($data);
I get an error message : Call to undefined method CodeIgniter\Session\Session::unset()
Or should I just destroy session and re-set it again?
Can anyone help me out here? Thanks in advance guys!
In CI4, need to do use
session()->remove($data);
further, please explore https://codeigniter.com/user_guide/libraries/sessions.html?highlight=#removing-session-data
Destroying a Session: https://codeigniter.com/user_guide/libraries/sessions.html?highlight=sessions#destroying-a-session
To clear the current session (for example, during a logout), you may simply use either PHP’s session_destroy() function, or the library’s destroy() method.
Both will work in exactly the same way:
<?php
session_destroy();
// or
$session->destroy();

cfajaxproxy is sending invalid parameters?

For some reason that I don't understand, on my development machine can't call to function of a cfc component from a cfajaxproxy.
In my cfm document:
<cfajaxproxy cfc="#Application.CfcPath#.empleado"
jsclassname="ccEmpleado">
This works, and also I can instantiate an object to get all the functions of that cfc component:
var cfcEmpleado = new ccEmpleado();
But, when I try to call a function of that object:
var nb_Empleado = cfcEmpleado.RSEmpeladoNombreBIND(1,1);
Debug complains:
Error: The ID_EMPRESA parameter to the RSEmpeladoNombreBIND function is required but was not passed in.
I got this from Network tab on Chrome and figured out that something is generating an invalid parameter:
http://127.0.0.1/vpa/componentes/empleado.cfc?method=RSEmpeladoNombreBIND&_cf_ajaxproxytoken=[object%20Object]&returnFormat=json&_cf_nodebug=true&_cf_nocache=true&_cf_clientid=41C92098C98042112AE2B3AAF523F289&_cf_rc=0
As you can see, there's a parameter [object%20Object], that is messing around my request, and that's why it fails. I don't why is happening this. Other people has tested this, and it works, but in mine doesn't.
I have Coldfusion 9, Apache, Windows 8. Is is some configuration issue on Coldfusion, or a bug?
I can't tell if this is your error or not, but it might be. This was a problem that we had for awhile. You should consider using explicit names to avoid any confusion. Add the "js" in there.
<cfajaxproxy cfc="cfcEmpleado" jsclassname="proxyEmpleado">
var jsEmpleado = new proxyEmpleado();
I will try to find a link to an article about this very thing.

ImageScaleToFit - how to implement?

I'm new to Railo, moving away from ColdFusion 8 where my site used to used to use cfx_imagecr3.
I believe Railo has ImageScaleToFit but I'm not sure if I'm using it correctly or if I need to add some kind of class/component? I've added it between a cfscript but i get 'invalid variable declaration' which doest make any sense to me. Any help appreciated.
I'm running railo-4.0.0.013 on ubuntu 12.04
<cfscript>
imageScaletoFit('/home/images/testimage.jpg','90','114','highestPerformance');
</cfscript>
You need to first load the image into a variable, then use that variable name inside ImageScaletoFit, like so:
<cfimage name="ImgVariable" source="/home/images/testimage.jpg" />
<cfset imageScaletoFit(ImgVariable,'90','114','highestPerformance') />
(This isn't specific to Railo - the function exists and works the same way in CF8+)

rails session_store odd behaviour

I am using active_record_store in a rails application which is storing this in session session[:email] = "email#address.com"
now this works fine in the action. but when this action gets over and is redirected to another page, which also accesses the same session[:email] I get an error
undefined method `eq' for nil:NilClass
this should probably mean that i am trying to compare values at some place i am not allowed to. but i cannot see anything like that in the code.
This looks like an old question, but I was just having the same problem and had to figure it out on my own, and thought I would post the solution up here for anyone else that runs into this. It's not very well documented, but to get this to work you have to add:
config.action_dispatch.session_store = :active_record_store
to application.rb, and
Application.config.session_store :active_record_store
to config/initializers/session_store.rb. Then, you have to do:
rake db:sessions:create
and:
rake db:migrate
Then, you have to restart your rails server. I think it was the db:sessions:create step that tripped up the original poster. Not only does that database table have to be laid out the way rails is expecting (that is, with an 'id' column, which is the actual cause of this error, I think), but also the current session has to have a valid ID. Hence the need to create the table and re-start the server, or potentially empty the table if it exists.

Creating an internal clock within Coldfusion .cfc file to execute scheduled tasks

I am needing to do scheduled tasks based off an ever going internal clock. I know this is possible with Javascript, but this solution will need to be hosted within a Application.cfc file. I tried to just use a "Now" function within a OnRequestStart function, however the problem is if I need to let's say send an email at midnight to someone, but no one makes a request at midnight, then the email won't send. I tried to do the same function as well in the OnApplicationStart function, but that will only run once ideally. I was thinking about using the CreateTime method within the OnApplicationStart function, but how would I increment the time in real time, if that makes sense. I hope this is more clear on what is actually needed. Here is some code I tried out, however I am not really sure how to test if this works honestly.
<cffunction NAME="internalclock">
<cfset today = #day(Now())#>
<cfset h = #hour(Now())#>
<cfset m = #minute(Now())#>
<cfset s = #second(Now())#>
<cfset m = #checktime(m)#>
<cfset s = #checktime(s)#>
<cfsetting requestTimeOut = ".5">
</cffunction>
<cffunction NAME="checktime">
<cfif i LESS THAN 10 > i="0"+i
<cfreturn i>
</cfif>
</cffunction>
Edit:
I'm having some issues accessing a variable within a page2.cfc file. The way the data is flowing is that I initialize the variable in an Application.cfc file, rewrite the same variable in page2.cfc, and access the modified variable in page3.cfm. Page3.cfm is just a test to ensure that the variable is in fact defined and updating as expected. I should mention that page2.cfc has a scheduled task on it and runs around every minute. Here is some example code:
Application.cfc
<CFFUNCTION NAME="OnApplicationStart">
<cfset Application.currenttime = 0>
</CFFUNCTION>
page2.cfc
<CFFUNCTION NAME ="Counter">
<cfset Application.currenttime = #Now()#>
</CFFUNCTION>
page3.cfm
<cfoutput>
#Application.currenttime#
</cfoutput>
The error I am getting is that either the current time variable is displaying as 0, or if I change the output to Counter.currenttime it says it's not defined. I am sure I am doing something dumb, but I would appreciate the help.
Thank you all for your help.
This can actually be done via Scheduled Tasks within Coldfusion Administrator. I didn't know that was a thing before actually making this post. My apologies.
Thank you,

Resources