I am currently trying to have one set cookie and the value of the cookie gets overwritten by PHP effectively when a user logs in, but it just creates a separate cookie, here is a snippet of code which am setting the cookie value
<?php
include("db_connect.php");
$input_game = $_POST['game'];
$input_user = $_POST['email'];
$sql = "UPDATE users_table SET Pref_Game = '" . $input_game . "' WHERE Email='" . $input_user . "'";
if ($conn->query($sql) === TRUE) {
$cookie_name2 = "content";
$sql="SELECT Pref_Game FROM users_table WHERE Email='$input_user'";
$result = $conn->query($sql);
$row = $result->fetch_object();
setcookie($cookie_name2,$row->Pref_Game, time() + (86400 * 30), "/"); // 86400 = 1 day
} else {
//Error
}
?>
Below is the JQuery cookie code just for clarity:
$("#test-cookie").click(function() {
$.cookie('content', 'test');
location.reload();
});
Is there anyway that PHP can update/overwrite the cookie value created by JQuery?