The cookie I set will not show up using IE or Firefox, although it does work if I add just a regular value to the cookie such as $customer_id = "idValue"; Is this because the session is created AFTER the setcookie function?
Here is the code I have now, but look down where the session is created, does this have something to do with why the cookie wont set?
<?php
//Start session
session_start();
$customer_id = $_SESSION['SESS_CUSTOMER_ID'];
setcookie("currentcustomer", $customer_id, time()+3600);
//Connect to mysql server
$link=mysql_connect("data.jcs5325.aisites.com","jcs5325aii_pho","203633");
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db=mysql_select_db("jcs5325aii_photography");
if(!$db) {
die("Unable to select database");
}
//Sanitize the value received from login field
//to prevent SQL Injection
if(!get_magic_quotes_gpc()) {
$username=mysql_real_escape_string($_POST['username']);
}else {
$username=$_POST['username'];
}
//Create query
$qry="SELECT customer_id FROM users WHERE username='$username' AND password='$password'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result)>0) {
//Login Successful
session_regenerate_id();
$customer=mysql_fetch_assoc($result);
$_SESSION['SESS_CUSTOMER_ID']=$customer['customer_id'];
session_write_close();
header("location: member-index.php");
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
}
}else {
die("Query failed");
}
?>