Global definition needed?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

Global definition needed?

Post 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?
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post 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.
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

Post by HiddenS3crets »

Thanks... I've been out of it for a while. Such a simple solution to a problem bothering me for hours.
Post Reply