Session problem

60 views
Skip to first unread message

Gael Princivalle

unread,
Oct 28, 2015, 12:10:57 PM10/28/15
to web...@googlegroups.com
Hello all.

I've got a strange problem with session.
I use PHPlist for mailing.
When the user click on a link in a PHPlist mail the URL is URL + some variables like &utm_source=emailcampaign6&utm_medium=phpList&utm_content=HTMLemail&utm_campaign=Newsletter+dell%27Azienda+Agricola+Mompal%C3%A0+-+01+-+Offerta+del+Mese+-+Composta+di+Pesche

In this page the user can add in session a product to the cart. But session is not available.
So it don't add any product to the cart.
In this case if the user is in the cart without any product I use session.flash for displaying a message like "Please add a product to the cart".
But it don't appear.

Also logging is impossible. The user can access to the login form, but sending it don't have any effect.

How can I force session to be created?

Thanks, regards.

Niphlod

unread,
Oct 28, 2015, 4:18:10 PM10/28/15
to web2py-users
are you aware that recent version of web2py by default renew session every time a user logs in / logs out for security reasons ?

Gael Princivalle

unread,
Oct 28, 2015, 4:29:47 PM10/28/15
to web2py-users
I'm running 2.9.12.
Anyway the problem is that I don't have any new session. All applications functions that use sessions are down.

In the same browser:
I click on the link in gmail.
In the application session is unavailable.
If I open a new tab in the same browser session still unavailable.
If I open the application in another "browse in private" window session is available.

Someone have a solution?

Anthony

unread,
Oct 28, 2015, 4:37:23 PM10/28/15
to web2py-users
Is the session cookie getting passed back and forth?

Niphlod

unread,
Oct 28, 2015, 5:05:57 PM10/28/15
to web2py-users
halt.

Given you "receiver controller" being
def index():
     session
.testmycart = 1
     
return dict(s=session)


Only two things can happen if no login is required:

a) either a user is coming back to the site (and the session isn't yet expired) and he gets

s = {'testmycart' : 1, 'previous_session_related_values' : 'bar'}

b) he is coming back with an expired session (the same thing happens if he was never on the site) and he gets

s = {'testmycart' : 1}


This will DEFINITELY happen in the same way if the user goes to http://host/a/c/f or http://host/a/c/f?utm_source=campaing&utm_campaign=baz


Gael Princivalle

unread,
Oct 29, 2015, 4:02:25 AM10/29/15
to web2py-users
Anthony, I'm sorry but I don't understand this question. I use session like a global session container for user information. Do I have to add some specific code for passing session thru the application?

Gael Princivalle

unread,
Oct 29, 2015, 4:20:07 AM10/29/15
to web...@googlegroups.com
Yes I can understand that it's unbelievable.
If you want to experience it you can make me a favor.

Website link to a product:

You can login:
Password: pofmario

And it works.

If you add this string after the URL:
&utm_source=emailcampaign6&utm_medium=phpList&utm_content=HTMLemail&utm_campaign=Newsletter+dell%27Azienda+Agricola+Mompal%C3%A0+-+01+-+Offerta+del+Mese+-+Composta+di+Pesche

and try again to login, nothings happen, and all session vars are unavailable.
Complete link:

A crazy thing is that adding the same string to another application there is the same problem.

If you want to order some organic products do it!!

Niphlod

unread,
Oct 29, 2015, 4:38:02 AM10/29/15
to web2py-users
we're clearly on a communication hiccup. here you're saying a user NEEDS to login. it complicates the things a bit in the workflow exposed earlier.

That being said, can you outline the workflow process ?
e.g. : user logs in, then clicks on the campaign, then the session is checked for "cart items presence" , etc etc.

Gael Princivalle

unread,
Oct 29, 2015, 4:48:14 AM10/29/15
to web...@googlegroups.com
No, I'm not saying that the user needs to login. I'm just saying that user login use session, and like all other functionalities that use session, in this case it's down.

I use login function for using a common function, avoiding to explain the cart workflow.

----------------------
Gael Princivalle

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/vuuMghopZUg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gael Princivalle

unread,
Oct 29, 2015, 4:49:04 AM10/29/15
to web...@googlegroups.com
No, I'm not saying that the user needs to login. I'm just saying that user login use session, and like all other functionalities that use session, in this case it's down.

I talk about login function for using a common function, avoiding to explain the cart workflow.

Gael Princivalle

unread,
Oct 29, 2015, 5:22:53 AM10/29/15
to web2py-users
For login it's mario at email.com

Anthony

unread,
Oct 29, 2015, 7:08:49 AM10/29/15
to web2py-users
If you add this string after the URL:
&utm_source=emailcampaign6&utm_medium=phpList&utm_content=HTMLemail&utm_campaign=Newsletter+dell%27Azienda+Agricola+Mompal%C3%A0+-+01+-+Offerta+del+Mese+-+Composta+di+Pesche

and try again to login, nothings happen, and all session vars are unavailable.
Complete link:

I cannot reproduce the problem. When I click the link above, I can add items to my cart and they persist in the cart. I can also log in and remain logged in, and the items that were already in my cart remain in my cart even after login.

Perhaps the problem is specific to your browser -- maybe your browser is not returning the session cookie. The session works by have the browser pass a special cookie back and forth with the session ID. On the server side, web2py associates that session ID with a session file that stores the session data. In your browser developer tools, for each request, you should be able to see all request and response cookies. Your session cookie should be named session_id_mompala_negozio_bio_torino. Confirm that this cookie is being passed in both the request and response, and that its value remains the same with each new request.

Anthony

Gael Princivalle

unread,
Oct 29, 2015, 7:54:14 AM10/29/15
to web2py-users
Well, thank you for your help. I cannot understand why you can't reproduce the problem. I've tried from Chrome and Firefox from Apple and Windows systems on 5 different computers, problem still the same.
Yes I can see the session_id_mompala_negozio_bio_torino cookie, before and after trying to add a product to cart. Value remain the same, but session seems empty.  

Anthony

unread,
Oct 29, 2015, 8:26:36 AM10/29/15
to web2py-users
Have you confirmed that the session actually is empty (e.g., add response.toolbar() to every page and check the content of the session on every request)?

Gael Princivalle

unread,
Oct 29, 2015, 9:50:38 AM10/29/15
to web2py-users
Certainly I don't know how reading the result of response.toolbar().
Also with session is ok, so without the string in the URL that give me problems, session cookies are empty:

cookies:
session_id_admin:85.38.152.82-8019b738-da8d-40ad-8c4a-60dd86a8b28c
comment:
domain:
expires:
httponly:
max-age:
path:
secure:
version:
session_id_mompala_negozio_bio_torino:85.38.152.82-6b6a929f-d8ee-4218-b08c-6086a0ec8382
comment:
domain:
expires:
httponly:
max-age:
path:
secure:
version:

I've let response.toolbar() in index, prodotti, and carrello pages, you can check it.

Anthony

unread,
Oct 29, 2015, 10:03:42 AM10/29/15
to web2py-users
The session cookies are not empty -- your app's session cookie has a value of 85.38.152.82-6b6a929f-d8ee-4218-b08c-6086a0ec8382.

Anyway to view the contents of the session, just click the "session" button on response.toolbar() -- it should expand and show you what is in the session. Initially, I see "cart" and "flash" keys in the session. If I add items to the cart, I then see them nested in the "cart" key. If you log in, you should also see an "auth" key in the session, with the auth.user details nested within it.

Anthony

Anthony

unread,
Oct 29, 2015, 10:09:30 AM10/29/15
to web2py-users

Below is what my session looks like (after logging in and putting item 37 with a quantity of 2 in my cart). The URL you posted is in my address bar:
http://www.mompala.it/prodotti?product_id=37&utm_source=emailcampaign6&utm_medium=phpList&utm_content=HTMLemail&utm_campaign=Newsletter+dell%27Azienda+Agricola+Mompal%C3%A0+-+01+-+Offerta+del+Mese+-+Composta+di+Pesche


Gael Princivalle

unread,
Oct 29, 2015, 10:30:21 AM10/29/15
to web2py-users
Yes clicking on session button I can see the cart values

In a first time I've check that with this link:
If I add a product as session is empty I redirect the user to the home page, and in fact session is empty. There's cart, but empty.

I've restart apache2. Now it works. Thanks again for your time Anthony, thanks Niphlod.
Reply all
Reply to author
Forward
0 new messages