I have recently started using a cfc component to store user information in the Session variable. I used to store them as individual variables in Session, such as Session.UserId, Session.Firstname, or Session.Lastname. This new component nicely wraps that all up for me into a component with get methods for each value I need (i.e. Session.User.getUserId(), Session.User.GetName(), etc).
But when I do a cfdump of the session variable for debugging, it displays the object structure's metadata. I'd like to see the values returned by the component's get methods. Any way of using a cfdump to output the function values with the object metadata?
<cfdump> isn't magic, all it does is output the value you give it. As your CFC instance doesn't expose any public properties reflecting these values, <cfdump> hasn't got any way of knowing what they are.
If you need to extract all the private properties reflecting your former session scope in one hit, then you need to create a method to do so, and then <cfdump> that. EG:
public struct function getVariables(){
return variables;
}
If you are abstracting the values you want further, eg into variables.sessionStuff (variables.sessionStuff.userId, variables.sessionStuff.name etc), then write a method getSessionStuff() which returns variables.sessionStuff.
Any way of using a cfdump to output the function values with the object metadata?
Yes, use accessors.
<cfcomponent accessors="true">
<cfproperty name="userID">
<cfproperty name="firstName">
<cfproperty name="lastName">
</cfcomponent>
Try to <cfdump> this object, you'll see the property values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With