Need help about SESSION

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
mlhazan
Forum Newbie
Posts: 3
Joined: Tue Feb 16, 2010 4:15 pm

Need help about SESSION

Post by mlhazan »

Please help me.I am working on a shopping cart project.What i am trying is use a session variable.The problem is when the user is logged index can get the $_SESSION['valid_user'] variable without an error but unlogged user get an error message on the page like :

Code: Select all

Undefined index: valid_user in /opt/lampp/htdocs/practice/log/test/index.php
if I make two different page one for logged and another for unlogged it will work but that way my project will become double.I know there is some where a way but need help.
I am stacked at this point and can't go farther .Please help me.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Need help about SESSION

Post by requinix »

You can use isset to check if a variable or element in an array exists.

Add to that some logic that decides what to do if they're logged in or not.
Post Reply