I know I'm generating sessions from moodle because I can get a
print "session id = $PHPSESSID
to give me my sessions (which I check via the /tmp directory and evidently are correct.) What I would like is to be able to yank the student id's, usernames and permission levels from the database when they login and store them as session variables for later access and inclusion. (It seems safer to do this than cookies)
Does the moodle login do this and I'm just missing it and if not, suggestions on where to start?
Question is, would it be better to do it here or in the setup.php file?
I was thinking just putting a session_register as a part of the get_user_info function. something simple like
for the variables I want to carry over. Of course, getting the correct permission levels from the database is the next step.
$SESSION->my_extra_id = $variable;
and it will persist automatically.
I think if you want to save things in the session variable you should use :
$SESSION['my_extra_id'] = $variable;
Not the syntax above.
But for what you seem to want to do you should find that setup.php is already reading the extra fields from your modified user table and putting it in $USER. $USER is actually a persistent variable which is stored as a Session variable and $USER contains everything from the user table.
Try print($USER->your_extra_fieldname); or print_r($USER); to see the data from the user table.
In fact here's what I was using to try to see the stuff (sessions are always initialized in the initial config file first thing.) You can see this at http://cabanisspc.uamont.edu/uam/surveys/
If you want to create an account, tis fine since this is still a work in progress.
Note that this is not within the standard context of moodle but in fact is a try at extending the capabilities. I use a standard moodle install for coursework and am quite happy with that. Still I had thought I could get the data from the table easier than it has come to be.
Try the following:
The thing is, it's a vanilla setup from a major distro. Something like this should not be giving us this much problem.
This will include setup.php as well. Don't try and start up sessions yourself. Setup.php will do all that for you.