PHP Function Help
- Started
- Last post
- 6 Responses
- u1sms
Please, can you please please help me? Basically I'm crap with PHP functions.
I have a form that gets sent to a validating script. At this point I retrieve the user_id and set that as a session variable. Then it go to the "homepage".
The "homepage" calls a function, which needs to use this session variable. However, each and everyway I try it's having none of it - maybe I'm just suffering from tunnel vision!
I've checked that the variable has been set, it's just the friggin' function that won't "see" it.
Thanks for any help ... and sorry for the long post!
- ethios0
You're probably having functions with variable scope, inside the function do
global $var;
If you ar ehaving probs with sessions,, make sure that session_start(); is at the top of every file
- u1sms0
Why can't I find things like that when I search!!
Thanks! You've made my day!
- deplifer0
You have to be sure that you call the Same Session scope on each page.
And start all the sesions with
the session_start(); callAnd if you give this session a name be sure to call the same
session.If different user are using this [app] be sure to have the session_scope to user_session.
This can be done by setttingSo each user has it own session.
And easy way to see what you have in the Session is by
copy this lines of code:::[php]
session_start();
foreach($_SESSION as $element => $value){
echo "$element : ".$_SESSION[$element]."";
}
[php]If you are using Objects to store user Sessions this is a different story.
- justjeff0
why wouldn't you just do
[php] print_r($_SESSION); [/php]
?
- deplifer0
Just for the eye's sake man.
If you want to debug alot and see your Array's values easier
Than Array(...);
That gets print out with print_r;Really annonying if you are working with alot of values inside an array.