After a lot of research i found out my solution to my problem, i just don’t know how to fix it. My current project is a shopping cart type project with a required login before viewing the shopping cart. I have a simple cart with a simple login script but both use a session. I just need to figure out how to combine the 2 to work together. Can anyone help me?
This is the login script session:
[php]<? ob_start(); session_start();include_once"config.php";
if(!isset($_SESSION[‘username’]) || !isset($_SESSION[‘password’])){
header(“Location: login.php”);
}else{
$user_data = “”.$_SESSION[‘username’]."";
$fetch_users_data = mysql_fetch_object(mysql_query(“SELECT * FROM members
WHERE username
=’”.$user_data."’"));
}
?>
[/php]
This is the script session for the shopping cart:
[php]<?php
require_once ‘library/config.php’;
require_once ‘library/category-functions.php’;
require_once ‘library/product-functions.php’;
require_once ‘library/cart-functions.php’;
$_SESSION[‘shop_return_url’] = $_SERVER[‘REQUEST_URI’];
$catId = (isset($_GET[‘c’]) && $_GET[‘c’] != ‘1’) ? $_GET[‘c’] : 0;
$pdId = (isset($_GET[‘p’]) && $_GET[‘p’] != ‘’) ? $_GET[‘p’] : 0;
require_once ‘include/header.php’;
?>
<?php require_once 'include/top.php'; ?> | |
<?php require_once 'include/leftNav.php'; ?> |
<?php
if ($pdId) {
require_once 'include/productDetail.php';
} else if ($catId) {
require_once 'include/productList.php';
} else {
require_once 'include/categoryList.php';
}
?> [/php]
and any help is very much appreciated. |