Link to home
Create AccountLog in
Avatar of SnoopJonny
SnoopJonnyFlag for United States of America

asked on

Session dropped when switching from HTTP to HTTPS

I'm developing a custom shopping cart site with JSP and Torque on Tomcat.  The customer shops for products at: 

and when they're ready to check out, they click a "check out" button and they're sent to:

but the session gets dropped.  The cart empties out on the secure side.  Both hosts are on the same machine and the same instance of tomcat.  I figured the problem might be the host names, so I tried starting out on:  and checking out with

and I have the same problem.  I want to avoid URL encoding because I have some flash navigation that I can't get rid of at this time.  I'm wondering if there's a solution I'm not thinking of.  I can grab the session id from the http instance of the site, but I don't know how to tell the https instance to use it.

Any help is appreciated.  Thanks!
Avatar of Mick Barry
Mick Barry
Flag of Australia image

its a bit tricky, simplest is to use https for the entire site
have a read of the solution offered here

There is a framework which deal the security on a very clear and declarative way - Acegi Security ( but you will have to introduce Spring framework ( into your project, in order that Acegi works. You can find a lot of articles on the net how to integrate this frameworks into your project (e.g.

Acegi could provide you a lot of things, but you can reuse it just for assiging which URLs (jsp pages in your case) will be forced to go through https (secure) connection and which should go always throught stardard http connection. This acegi filter is called securityChannelProcessingFilter and the configuration would be something similar to next code (all jsp pages under /secure folder will be forced to go over secure channel - all other jsps must go over insecure - http channel):

	<bean id="securityChannelProcessingFilter" class="org.acegisecurity.securechannel.ChannelProcessingFilter">
		<property name="channelDecisionManager"><ref bean="channelDecisionManager"/></property>
		<property name="filterInvocationDefinitionSource">

Open in new window

Avatar of Kuldeepchaturvedi
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of SnoopJonny


I must have had a secure cookie pre-set that was prohibiting me from seeing that this was working.
Sometimes All it takes is second pair of eyes...:-),
Glad to be of help.
Thanks for the help!