how to cookies data automatically stored - cookies

I added the cookie manually using get and set method but my question is how to show user activity and how to store user activity, how to cookies data automatically stored.
I didnt show the user activity

Related

What happens to a User-ID in google analytics when the user clears the cookie?

I am trying to implement the user ID feature in Google Analytics to track user behaviour across devices. I know that the client ID gets cleared once the user clears the ga cookie.
What happens to the user ID in this case? Is it tied to the authentication system and hence not dependent on the cookie? Can someone throw some light on this?
You have to generate a unique user id for ervery user and store it.
Everytime the user logs in to you site, you have to set correct the user id.
Take a look to this document.
Google Documentation
The id that you will pass should be a unique id from your system that persists.
If the user clears their cookies, it will not matter because the user id will reset once they access a page next time.

How to retrieve again, the user data from Facebook API?

I have a bunch of data in a table from users who authorized the app on my site, but the data is corrupted, I have users with profile id registered and users without this information, users with only part of the data, without names, etc.
I need to update theses data, and get the profile id for all of them, so how do I retrieve again the data from Facebook for all theses users?
There is no way to get a list of users who authorized your App, which is what you would need. You can only get the ID (or any data) the next time they visit your App. Except you have stored an Extended Access Token that is still valid, but i guess that´s not the case.

How Do I Deal With Django Session Data for Storing Users ID?

This may sound too easy to understand but I am not sure I am having my head around it.
When a user is signing up in the first page of my app, I have request.session['user_id'] set which is used in page two of the sign up to complete registration. The user_id is the primary key to user in USER TABLE but I don't want to store user_id in session. I fear it might be tampered with and the WRONG row might get updated.
I would want something like a token that would be generated by my script but Django's SESSION TABLE only has three columns (session_key, session_data, expire_date) and it saves session details to it automatically.
My questions precisely are:
Can I tinker with the SESSION TABLE and add a session_token to it or I have to create my own table?
How do I get the session_token to automatically save like other columns in Django SESSION TABLE?
Or is `request.session['user_id'] okay and safe?
Do all these also apply to COOKIES and why do I need to use cookies when SESSION_EXPIRE_AT_BROWSER_CLOSE is set to FALSE?
The session is stored in the database, not in the user's cookie. There is no way for the user to change that data. The only thing stored in the cookie is the hash of the session ID itself.

django save a form for a user that has not registered yet

I need some advice / ideas if someone is inclined to help: I have a javascript interface for manipulating pictures. Basically it's about moving photos around. Once it's done the position of images is saved into a Django form and then saved to database with the owner saved as the current user. Now the trick is that I would like to be able to allow non registered users to play with this interface and then if they like the result they hit save and are redirected to an account registration page and only then the form is actually saved with their user as the owner.
What comes to my mind now is to keep the values of the form in session but I don't know what will happen to the session once the anonymous user registers and becomes another user. I was also thinking of using a 'next' parameter in the registration process with the url filled with get parameters that would be the content of the form but then I don't know if userena is ready to allow that.
Any light on this is welcome.
Well, we did similar thing on our site.
When unregistered user attach photos we save objects to database and assign unique hash which was generated when user came to the page with form. When user hit submit we pass this hash in url and on the next step, when user wants to register, we just get objects from database by this hash and assign user_id to them.
Also we have a cron job which do clean up and removes all lost objects
P.S. Sorry for my english i hope you'll get my point
Save the object without the user and store a reference of that object in the session (or (signed) cookie). If if the user registers, update all the objects with the newly created user.
Another approach would be to store the data in the browser (html5 localstorage and fallbacks, or similar) and only insert it into the database once the user has signed up. You would need to make sure both things happen inside the same browser 'instance', but things would be easier in the server side.

Django Registration Number of users logged in

I have an application where I would like to display the number of users that are logged into the system. Im trying to determine the cleanest way to do this that will not create a large load on the system.
I know that the system keeps track of the "last logged in time" So I could do a query and aggreate the number of users whose last login is within a given time?
Are there better solutions??
Any thoughts are welcome!! Please.
Using the last logged in time doesn't work. Your sessions can last for days/weeks so you won't know the amount of active users that way.
One solution would be to create a table with login sessions where you store that session id in a session cookie. Session cookies expire once the user has closed his/her browser window so it should give you quite an accurate estimation of when people logged in. If you actually want to store the entire session duration, than you will also have to update the table with every page view to store the time that the user was last active. This would be slightly heavier for your database ofcourse.