Page 1 of 1

Global definition needed?

Posted: Fri Jul 06, 2007 11:52 am
by HiddenS3crets
I have a login script where when someone logs in, it loads a user_info array with information about the user that can be used around the site

Code: Select all

<?php
$use_info[0] = <username>;
$user_info[1] = <register_time>;
// etc
?>
That is in the login.php file.

Now I want to access that information through other files, but have been unsuccessful.

Is this an issue of scope? Correct me if I'm wrong, but I believe it's because the scope of the array is the login file. How can I access these values?

Posted: Fri Jul 06, 2007 12:00 pm
by guitarlvr
you can create a session. start the file (and any other page they go to) with session start(). Then for your array, make the variable

Code: Select all

$_SESSION['user_info'] = $user_info[]
Then you will be able to access the session between pages.

Posted: Fri Jul 06, 2007 12:09 pm
by HiddenS3crets
Thanks... I've been out of it for a while. Such a simple solution to a problem bothering me for hours.