RESOLVED Lost session variable value

I’m Frank

I have the following problem create an application with a login form that validates user data and then store them in session variables which are then used in other applications in the system I created that need to know that user has entered to display the information.

the user gains access without problems and see what personal information but after using the different menu options available to him in a time period less than 2 min the values of session variables are lost

someone could say that I am doing wrong?

Here Login Form Code Example

sc_lookup(dtget_logged_user,“SELECT user_id
,type_user_id
,email_verify
FROM tb_mst_login
WHERE email = ‘$user_name’ OR username = ‘$user_name’
AND password = ‘$encrypted_pass’”);

sc_set_global([login_user_id]);   
sc_set_global([vcompany_id]);   
sc_set_global([cv_id]);   
     
[login_user_id] = {dtget_logged_user[0][0]};	


[user_type]  = {dtget_logged_user[0][1]};
$isEmail_Verify = {dtget_logged_user[0][2]};
$isValid_user = 1;

Re: Lost session variable value

It is hard to say … I may get arguments on this, but I prefer to create my own session variables instead of using the macros in SC. You have more control and all sc_set_global is doing is creating a session variable for you anyway. It is possible that your variable is colliding with your field name variable and it overrides it. I have seen this many times.

Try and use PHP when possible instead of relying on sc_macros.

$_SESSION[‘user’][‘id_user’]
$_SESSION[‘user’][‘user_type’]
$_SESSION[‘user’][‘id_company’]

$_SESSION[‘appname’][‘my_var’]

is a lot cleaner than

sc_set_global([login_user_id]);
sc_set_global(…);

And you are guaranteed not to have variable collision.

you can then use:
print_r($_SESSION[‘user’]) to view all elements of user

Regards,
Scott.

Re: Lost session variable value

thank you very much for your advice helped me a lot. Reflections on overwriting your variables reminded me that I was sometimes described as a session variable, post and get in the configuration of the application. change it only as session variables everything works perfectly

Thanks again Scott

Re: RESOLVED Lost session variable value

Hi,
Is is possible to make session varaible Read only…?

I have [v_login] varaible declared in the Login screen and making global to across the project sc_set_global([v_login])

When we pass the variable to other application using sc_redir macro It gets modified… The fun here is why should it get modified. The code is as below

sc_redir(form_users_int,v_login=$wflogin;v_username=[v_username];wf_login=$wflogin,"_self");

Issue :

The Variable is availble in all the application, That is fine, but when some applications modifies [v_login] then It get modified.

for ex: I had logged in as Dhana and In the User Manager screen, I use the same variable name to passs to Form application in which Editing other username say “Ben” then the [v_login] holds the new value not the orginal One

How to make session varaible readonly …>?

Any one has more view…! Please share…!

Regards
Dhana

Re: RESOLVED Lost session variable value

Hi Dhana,

do what Scott suggests … this is the best way.

Re: RESOLVED Lost session variable value

The variable only is modified if you change the value in any part of your project.