saving django session data for anonymous user

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

saving django session data for anonymous user

Siddharth Srivastava
Hi ,

i was writing small ecommerce application in django framework. so i was trying to implement add to cart functionality like that if user is anonymous user then selected products should be mapped to it's session id which is act. cart id in models. so the scenario is that whenever anonymous user check out and mapped data against that session id is purged. Is there any mechanism to save anonymous user session data even after user logs in. kindly provide easy possible solution as i am bit new to django:)

Thanks,

Siddharth


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: saving django session data for anonymous user

Anthony Flury
The only way I can think of is when your user goes to log in - check if
their session id is already recorded.

When they login - I assume that they get an new Session Id - and remap
the data from their old session id to their new session Id.

Would that work ?

On 12/06/18 11:01, Siddharth Srivastava wrote:

> Hi ,
>
> i was writing small ecommerce application in django framework. so i
> was trying to implement add to cart functionality like that if user is
> anonymous user then selected products should be mapped to it's session
> id which is act. cart id in models. so the scenario is that whenever
> anonymous user check out and mapped data against that session id is
> purged. Is there any mechanism to save anonymous user session data
> even after user logs in. kindly provide easy possible solution as i am
> bit new to django:)
>
> Thanks,
>
> Siddharth
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> To post to this group, send email to [hidden email]
> <mailto:[hidden email]>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com 
> <https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--
--
Anthony Flury
email : *[hidden email]*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/afd880e5-38ee-e2db-6491-b53e9c69d40f%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: saving django session data for anonymous user

Melvyn Sopacua
In reply to this post by Siddharth Srivastava

On dinsdag 12 juni 2018 12:01:32 CEST Siddharth Srivastava wrote:

 

> so the scenario is that whenever anonymous

> user check out and mapped data against that session id is purged. Is there

> any mechanism to save anonymous user session data even after user logs in.

> kindly provide easy possible solution as i am bit new to django:)

 

 

Well, the easy solution is to follow the documentation:

 

Note that any data set during the anonymous session is retained in the

session after a user logs in.

 

--

Melvyn Sopacua

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1614496.8M6cUJZ5yO%40fritzbook.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: saving django session data for anonymous user

Siddharth Srivastava
In reply to this post by Anthony Flury
Thanks  Anthony for your prompt reply. current implementation is that i am using django orm query to pull the user cart details and cart id(session key) is the key so when user switch from anonymous
user to actual user then i loses the data came from the query. 

so when user gets authenticated then it create new session id then previous session data we lose. I am not finding much help in google:(.

Thanks,

Siddharth



On Tue, Jun 12, 2018 at 8:37 AM, Anthony Flury <[hidden email]> wrote:
The only way I can think of is when your user goes to log in - check if their session id is already recorded.

When they login - I assume that they get an new Session Id - and remap the data from their old session id to their new session Id.

Would that work ?

On 12/06/18 11:01, Siddharth Srivastava wrote:
Hi ,

i was writing small ecommerce application in django framework. so i was trying to implement add to cart functionality like that if user is anonymous user then selected products should be mapped to it's session id which is act. cart id in models. so the scenario is that whenever anonymous user check out and mapped data against that session id is purged. Is there any mechanism to save anonymous user session data even after user logs in. kindly provide easy possible solution as i am bit new to django:)

Thanks,

Siddharth


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email] <mailto:[hidden email]>.
To post to this group, send email to [hidden email] <mailto:[hidden email]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com <https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--
--
Anthony Flury
email : *[hidden email]*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAENVTMq%3DUUZ%3D_o-GVpcT8LsgeLGTYEQpa2Urjv8h97jgLONMBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: saving django session data for anonymous user

Anthony Flury
How are you authenticating them ?

Assuming you call :

         authenicate( username, password)

then before that call - store the sesssion key

after that call - identify the new session key

with the old and new session keys - now update the database - so that
the cart gets associated with the new session key.


On 13/06/18 13:40, Siddharth Srivastava wrote:

> Thanks  Anthony for your prompt reply. current implementation is that
> i am using django orm query to pull the user cart details and cart
> id(session key) is the key so when user switch from anonymous
> user to actual user then i loses the data came from the query.
>
> so when user gets authenticated then it create new session id then
> previous session data we lose. I am not finding much help in google:(.
>
> Thanks,
>
> Siddharth
>
>
>
> On Tue, Jun 12, 2018 at 8:37 AM, Anthony Flury
> <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>     The only way I can think of is when your user goes to log in -
>     check if their session id is already recorded.
>
>     When they login - I assume that they get an new Session Id - and
>     remap the data from their old session id to their new session Id.
>
>     Would that work ?
>
>     On 12/06/18 11:01, Siddharth Srivastava wrote:
>
>         Hi ,
>
>         i was writing small ecommerce application in django framework.
>         so i was trying to implement add to cart functionality like
>         that if user is anonymous user then selected products should
>         be mapped to it's session id which is act. cart id in models.
>         so the scenario is that whenever anonymous user check out and
>         mapped data against that session id is purged. Is there any
>         mechanism to save anonymous user session data even after user
>         logs in. kindly provide easy possible solution as i am bit new
>         to django:)
>
>         Thanks,
>
>         Siddharth
>
>
>         --
>         You received this message because you are subscribed to the
>         Google Groups "Django users" group.
>         To unsubscribe from this group and stop receiving emails from
>         it, send an email to [hidden email]
>         <mailto:django-users%[hidden email]>
>         <mailto:[hidden email]
>         <mailto:django-users%[hidden email]>>.
>         To post to this group, send email to
>         [hidden email]
>         <mailto:[hidden email]>
>         <mailto:[hidden email]
>         <mailto:[hidden email]>>.
>         Visit this group at
>         https://groups.google.com/group/django-users
>         <https://groups.google.com/group/django-users>.
>         To view this discussion on the web visit
>         https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com
>         <https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com>
>         <https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com?utm_medium=email&utm_source=footer
>         <https://groups.google.com/d/msgid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>         For more options, visit https://groups.google.com/d/optout
>         <https://groups.google.com/d/optout>.
>
>
>
>     --
>     --
>     Anthony Flury
>     email : *[hidden email]
>     <mailto:[hidden email]>*
>     Twitter : *@TonyFlury <https://twitter.com/TonyFlury/
>     <https://twitter.com/TonyFlury/>>*
>
>

--
--
Anthony Flury
email : *[hidden email]*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e341aaeb-62b8-9071-181c-32305a9f08cf%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: saving django session data for anonymous user

Melvyn Sopacua
In reply to this post by Siddharth Srivastava
On woensdag 13 juni 2018 14:40:05 CEST Siddharth Srivastava wrote:
> Thanks  Anthony for your prompt reply. current implementation is that i am
> using django orm query to pull the user cart details and cart id(session
> key) is the key so when user switch from anonymous
> user to actual user then i loses the data came from the query.
>
> so when user gets authenticated then it create new session id then previous
> session data we lose. I am not finding much help in google:(.

This is a very bad design. Why don't simply store the cart ID in the session,
rather then using a session ID for a cart's ID? This is just one of the
problems you're going to face.
For example, implementing abandoned cart reminders is going to be no joyride
and pretty much standard functionality in e-commerce these days. Sessions are
there to store data and Django automatically copies the data in the session
from anonymous user to logged in user. It's what sessions are made for.

--
Melvyn Sopacua

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3751359.ac4gruEBS1%40fritzbook.
For more options, visit https://groups.google.com/d/optout.