How to define a variable on one mage, and make it available

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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

How to define a variable on one mage, and make it available

Post by infolock »

Could someone tell me how to make a variable I define on one page, available to any other page I want to call it from ?

Example:

Login.php has 2 text boxes. One is named user, the other is named pwd.

Then, on my authentication script, I give each post value a variable name:

$username = $_POST['user'];
$password = $_POST['pwd'];

It then forwards me to a "User Main Menu" page, of which I want to say "Welcome $username", where $username = post value.


I know this has to be very easy... I've looked in my book, but I must be over looking how to do this... Any help is appreciated.
Doolittle
Forum Newbie
Posts: 19
Joined: Sun May 04, 2003 11:45 pm

Post by Doolittle »

Sessions are what you want...

http://www.php.net/manual/en/ref.session.php
User avatar
zoki
Forum Newbie
Posts: 9
Joined: Tue Apr 23, 2002 3:09 pm
Location: Serbia
Contact:

Post by zoki »

You use either cookies or sessions to do that.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

yeah, I know how to name a session, and start a session.. but that page you just posted doesn't tell me how to use a variable in order to define a session name, or how to call it later...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Maybe one of the stickies can help:
Before Post Read: Sessions with a Minor in User Logins

Mac
Post Reply