View Full Version : problem in login page

09-12-2005, 07:14 AM

i am just making a small cart. In which there is a members area. each member is signup to buy products. Suppose one user is login through its proper userid and password, and put his selected items in cart. And then that user go to the home page of the site.

I want if user is already login through his userid and password, then my shopping cart did not ask the user to signin again, when he add another item to cart

how can i implement this

09-12-2005, 07:56 AM
One solution of the problem is using cookies. You first check whether there is a user via cookie and if there is you don't open the login form else you will open the login form

09-12-2005, 11:07 AM
It depends, if you are storing sensitive data (what someone orders should be kept secret?) then sessions are the best choice.. Here is some pseudocode

select the user from the user table where that users name is equal to $username and password is equal to md5($password)

if that query returns 1 row then
set the session variable to the value of $username

To check if they are logged in (in code)..

if(isset($_SESSION['sessionvar'])) {
echo "hello, you are logged in";
} else {
echo "hello, you are not logged in"; }