i want to start a new session using a cookie, once the previous session has been destroyed.
if a cookie is set, but not a session, can i automatically, create a new session using only the cookie?
currently, i am implementing a remember me button. and part of my loggin code is
if($rememberme=="on"){
$user_id=mysql_result($query_run,0,'id');
setcookie("user_id",$user_id,time()+7200);
$_SESSION['user_id']=$_COOKIE['user_id'];
header('Location:front_page.php');
}else if($rememberme==""){
echo'ok';
$user_id=mysql_result($query_run,0,'id');
echo $user_id;
$_SESSION['user_id']=$user_id;
header('Location:front_page.php');
i need to do this because if a cookie is set, but not a session, it is causing various errors on my site. because i am using the $_SESSION['userid'] variable in various places. and if the session is not set, many of my functions are not working
edit: i tried the following and it did not work.
i want to start a new session using a cookie, once the previous session has been destroyed. any other suggestions?
set_session_from_cookie();
function set_session_from_cookie(){
if(isset($_COOKIE['user_id'])){
$_SESSION['user_id']=$_COOKIE['user_id'];
}
}