Kürzlich mein PHP Session-Cookie funktioniert nicht mehr auf localhost, aber wenn ich die gleiche Datei online hochladen funktioniert es sehr gut, ich weiß nicht, was ich falsch gemacht habe.php session cookie startet nicht auf localhost aber funktioniert online
Hier ist mein Code, um eine Sitzung bei der Anmeldung zu starten.
<?php
define('sessionservername', '.example.com');
$Lifetime = 365 * 24 * 60 * 60; //31536000; // set cookie life time
$sessionTime = 365 * 24 * 60 * 60;
ini_set("session.gc_maxlifetime", $Lifetime);
ini_set("session.cookie_lifetime", $Lifetime);
ini_set("session.gc_divisor", "1");
ini_set("session.gc_probability", "1");
function sec_session_start(){
session_name();
$secure = false;
$httponly = false; /*This stops JavaScript being able to access the session id */
// Forces sessions to only use cookies.
if (ini_set('session.use_only_cookies', 1) === false) { header("Location: login.php?err=Could not initiate a safe session");exit();}
$cookieTimeer = 365 * 24 * 60 * 60; //31536000;
$cookieParams = session_get_cookie_params();
session_set_cookie_params($cookieTimeer, $cookieParams["path"], '.example.com', $secure, $httponly);
session_start();
}
?>
Thank auf jeder Seite ich diese Zeile hinzugefügt
<?php
session_set_cookie_params($sessionTime, "/", sessionservername, $sessionsecure, $sessionhttponly);
session_start();
?>
Huh ... Cookie funktioniert nicht mehr? Was bedeutet das? –
@bub, ich meine, dass meine Sitzung nicht wieder auf localhost beginnt – Peter