[Answered ]-Notify user about bounced confirmation emails

1πŸ‘

βœ…

You probably want to use Django sessions system. It is enabled by default in Django projects created with manage.py startproject.

Basically, the SessionMiddleware adds a session attribute to all requests performed to your Django project. You can use this attribute as a standard python dict in your views:

def my_view(request):

    # At some point, you retrieved the visitor email...
    user_email = 'john@example.com'
    request.session['user_email'] = user_email

Information stored in this dict are persistant by default.

Technically, the data stored in this dict are stored in your default DB, in table django_session. A unique session_key is associated with those data, and this key is stored on your visitor computer in a cookie. This means the data has an expiration date. When the user come back to your website, if the cookie is still present (and not outdated), you can retrieve the information in request.session as you stored it some days before.

Django sessions persistency behavior can be controlled with 2 settings:

False by default. If set to true, sessions are destroyed when the user close his browser. You probably want to keep this value set to False.

This is the default duration of sessions, in seconds. Default is 1209600 corresponding to 2 weeks.

Note: you can modify the session duration by directly calling request.session.set_expiry(). This allows to override the default settings on a per-session basis.

πŸ‘€Antwane

1πŸ‘

Typically I’m not so sure that its a great idea to rely on being able to identify returning anonymous sessions.

Another way to handle this issue that I’ve seen farely often is to allow the user to complete their registration, and be able to log in with their username and password, but mark the user as unverified, perhaps with a field on a user profile model. Unverified users can simply be denied access to the bulk of your site. And after logging in they can request to have their verification email sent again if they haven’t yet received it, as well as having the option to update their email if they made a mistake.

It looks like the django-registration app helps with a lot of this.

Docs: https://django-registration.readthedocs.io/en/2.2/install.html

0πŸ‘

Tobitobs, as another way: you can attach anonymous email to his localStorage bucket, and later you can get this back. But I user clears cookies and another data in browser – these emails cloud be lost.

One more way – to save emails with a snapshot of device – browser-device-os-IP (or something) and store this info at DB.

πŸ‘€Oleksiy

Leave a comment