Session management HTTP->HTTPS

I'm passing the session id in the url when I move to an https page and this works fine for in page sessions as I set the session_id($_GET['sid']);
When I call another page with ajax the session is ignored and a new one started.
This is in FF, in IE it seems to work fine.
LVL 58
GaryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
You can set your own cookie for the session.  I believe that you can set it so that the session cookie will be returned for both HTTP and HTTPS.  

But there may be a timeliness component here, too.  Check to make sure something like this is not happening to your scripts.  In a recent test, I tried setting a cookie in a script that was a long-running-job (over 40 seconds) and getting the cookie in another script to check the progress of the long-running-job.  It didn't work in either FF or Chrome.  Neither of those returned the cookie until after the first script finished execution.  I did not test IE.

Just curious...  Why not put the whole operation behind HTTPS?  Why switch back and forth?
0
GaryAuthor Commented:
The reason I cannot use the same session is because the domain is slightly different.
But the question is why is FF screwing up the session when I manually set the ID, while IE works fine.
I may have to pass the session id in the ajax calls if no one knows...
0
leakim971PluritechnicianCommented:
do you remember this time :

    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

// M. Jackson
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

GaryAuthor Commented:
@leakim
Uhhh?

@Ray
It would be stupid running a shopping cart on https for the whole thing, just unnecessary
0
leakim971PluritechnicianCommented:
LOL

You said :
But the question is why is FF screwing up the session when I manually set the ID, while IE works fine.

IE and FF don't do ajax call the same way
0
GaryAuthor Commented:
But I'm manually changing the session id, ajax shouldn't have anything to do with it.
0
leakim971PluritechnicianCommented:
When I call another page with ajax the session is ignored
0
GaryAuthor Commented:
I don't see your point leakim
I set the session id at the server with php, why would a new session be started on the same protocol/domain
0
leakim971PluritechnicianCommented:
use fiddle and let me know if you see the session during the ajax call (on FF and on IE)

if it's possible provide a link to the page or build a simple one to reproduce
0
GaryAuthor Commented:
Fixed it.
I was checking if session_id had a value and then starting the session if it didn't, but because I was manually setting the session_id the session wasn't getting started.
So a rejig of the code and now it works fine.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
"It would be stupid running a shopping cart on https for the whole thing, just unnecessary"

Facebook and Google don't think so.  They're running Everything on HTTPS now.  What is your objection?
0
GaryAuthor Commented:
Only for logged in users.
My objection is why encrypt non sensitive information and add extra load to the server
0
Ray PaseurCommented:
It would be stupid running a shopping cart on https for the whole thing, just unnecessary
I asked the server and she said she didn't mind encryption, in fact she kind of enjoyed it!

Anyway, glad you found a solution, but it doesn't make me entirely comfortable that one browser would work and another would not!
0
GaryAuthor Commented:
Solved myself
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.