Forum Moderators: coopster

Message Too Old, No Replies

keeping SESSION alive switching to SSL connection

         

foy

4:42 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



Hey there,

I use a session script which should pass all variables to a secure connection.

Like when someone enters [mydomain.com...] he is able to to fill a shopping cart (no ssl) and can switch to a secure connection (let's assume it's [mydomain.com)...]

but however all my session data is lost once I switch to an SSL connection. How can I get the session data to be available through both connections?

My session script looks like this:


<?php
session_cache_limiter('private');
session_cache_limiter();
session_start();
if(isset($HTTP_GET_VARS["session_id"])) {
$_SESSION["session_id"] = $HTTP_GET_VARS["session_id"];
$session_id = $HTTP_GET_VARS["session_id"];
}
if(!isset($_SESSION["session_id"]) ¦¦ $_SESSION["session_id"] == ""){
$_SESSION["session_id"] = session_id();
}
$session_id = $_SESSION["session_id"];
if(isset($username) && $username!= "") {
$_SESSION["username"] = $username;
$username = $_SESSION["username"];
}
?>

So I want the session_id and username to be available on SSL as without SSL.

any ideas?
I also do not want to set a cookie specifically using setcookie since I want the session only to be alive during open browser window, once it's closed the session should be gone...

thanks in advance

mcibor

6:53 pm on Aug 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is explicitly in setcookie.
On session_start() you set a session cookie, which is normally ok. However on ssl you change http: to https and for the cookie that's a different domain, so you lose it.

What I could reccommend is in this case passing sessionID in url once
<a href="https://www.example.shop.com/secure.php?<?php echo SID;?>&action=buy">Go to cart</a>

I hope this explains things a bit. However I don't know how it is done in other shops - you may have a look there and try to discover the way

Michal Cibor