How to keep the user logged in after the successful transaction.
I am using eCart 4. I run the site in localhost and I use the paypal express checkout sandbox to test the payments. I have seen that I must clear the session variables otherwise the cart stays with its previous content and the order summary and details tables do update and not insert of the subsequence order submission. To clear the session I put this code at the end of the pp_checkout_success.php page.
<?php
if (!session_id()) session_start();
unset($_SESSION);
session_destroy();
?>
But this code clears also and the logged in session variables that is the user is getting logged out. I tried this code to keep the user logged in
<?php
$sid=$_SESSION['sid'];
$semail=$_SESSION['semail'];
$sname=$_SESSION['sname'];
$scheck=$_SESSION['scheck'];
if (!session_id()) session_start();
unset($_SESSION);
session_destroy();
if (!session_id()) session_start(); ----- This is line 344
if (!isset($_SESSION['sid'])) $_SESSION['sid']=$sid;
if (!isset($_SESSION['semail'])) $_SESSION['semail']=$semail;
if (!isset($_SESSION['sname'])) $_SESSION['sname']=$sname;
if (!isset($_SESSION['scheck'])) $_SESSION['scheck']=$scheck;
?>
By this way the user stays logged in, the cart empties and subsequence order works normally but I get the following warning
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\xampp\htdocs\pp_checkout_success.php:132) in C:\Program Files\xampp\htdocs\pp_checkout_success.php on line 344
Line 132 is inside the template code and handles the logged in information for the whole site
I would be grateful for any help