Most web analytic tools monitor user activity on a website but don't map it to a particular user. If my web application requires users to log in, is there a way I can track the progress of the logged in user as he/she goes through the web application?
So in a nutshell, this is something like Google Analytics. But instead of anonymous users, I want to map the browsing habits of someone to a user in my database. Thanks!
You can create a MySql DB with user activity functions that will be triggered as the user lands on different pages and executes different modules. with php you can also track ip address and log user activity on the server side.
function activity_track($user, $activity){
$user = $user;
$activity = $activity;
$actIp = $_SERVER['REMOTE_ADDR'];
//write to db
}
then you can call this function anywhere like this:
activity_track("Me", "testing this sweet system");
Related
I am working on an application that allows a social worker to conduct mental health assessments with their clients (usually children). This process normally happens face to face. A question is presented on a page, the social worker reads it to the client and the client indicates their answer (multiple choice from sad smiley to happy smiley), they click next and the next question is presented. I am trying to implement a feature to allow this process to happen remotely.
At the moment, only social workers have logins. The clients details are all in the db, so I would like to be able to email or sms a link with an authentication token that allows the client to have temporary access just to the questionaire page.
I am planning to use an API like pubnub or pusher to have the selected answers update on both the social workers view and the clients view as they change, so they can work through the questions together.
I am very new to Laravel and I am unsure how to go about creating a temporary session.
Looking at the documentation, there seems to be a number of ways to do authentication.
How should I approach this?
You can use signed URLs in Laravel. https://laravel.com/docs/7.x/urls#signed-urls
Signed URLs can be temporary, from the docs:
use Illuminate\Support\Facades\URL;
return URL::temporarySignedRoute(
'unsubscribe', now()->addMinutes(30), ['user' => 1]
);
later in your controller:
if (! $request->hasValidSignature()) {
abort(401);
}
We have an API which connects to our own first party applications. Our API is sending out notifications based on user actions or if there is an update to the application etc.
Our API is modular structured.
Example
Our user model in API is located in App\Modules\Accounts\Models\User. Each month we send an invoice database notification to user from our API. In database it adds the notification and the notifiable_type is App\Modules\Accounts\Models\User.
But in our user application the user model is located in App\Modules\User which results user having 0 notifications.
Question
I know I can move the user model to exactly the same path in the user application but it seems somewhat wrong. Is there a way to tell the user model in our user application where to receive database notification on? Something like:
public function(){
return $this->receivesNotificationsFrom('App\Modules\Accounts\Models\User');
}
I would solve this in api as like this (suggesting, i would also use your namespace for users like you did, what i would never do, but lets suggest it). There are several ways to test, what is the best solution for you.
I would:
In your consuming app, you create a new model App\Modules\Accounts\Models\User that just extends your existing User class. I would test, if i can get to goal with this approach.
You create an artisan command to just rename the classes in your notification table and let this run by laravel's scheduler, so in your notifications table are the correct namespaces for your app.
This all "feels" wrong and i would never break with the defaults of App\User, because you run into traps like this and end up with "messy" solutions like 1 or 2.
Sry, i have no better ideas now, but maybe, it gives you some little inspirations 😉
I have a live application for my app,(say at mysite.com). As part of my customer on boarding, I have a demo site at (demo.mysite.com), this is where I show potential customer what the app can do, etc. (Different databases and url). In order manage my system, i created also an admin panel on my live site.
Is it possible for me to control the demo site from my live site admin panel. I need to perform activities like,
After a user signs up on live site for a demo account, I create a demo customer via the admin panel after reviewing the request. Which means I need to access the demo site via controller to make a new "demo" customer model, is this possible? I know that I can make multiple mysql connections from live. But how can I perform Eloquent model operation from my live site?
Should I set up a different set up for my demo site.? Is this over complicated? I can set-up a demo accounts for my potential customers on my live site as well. I chose this set up thinking that it's safer in terms protecting data on my production site.
$demoUser = App\User::on('demo')->create([
//your attributes
]);
Here is an example how you can achieve an Eloquent operation on another connection. The on method returns a Illuminate\Database\Eloquent\Builder instance, btw you can go on and do whatever you want.
I have an account called users. When a user logs in they view information specific to them. When another user logs in they view the other users information. What do I need to do to ensure logged in users only view their information only?
You can use $user = $request->user(); to get the user and return it as a variable with the view for the profile page. Then you can use the user variable to get the rest of the user's data.
Can Codeigniter allow multiple users login with the same username ? and also making a refresh page every people who have same username ? for example, having 3 people login with the same username in different places. Person A uploaded file then redirect to the same page and not had an upload button. The button will disappear after Person A used. The question is How can I made Person B and C not see an upload button after Person A used it. Redirect with sending session id then refresh ? Any idea ?
Wow, that's quite a system. If you're implementing the login and using Codeigniter sessions, then: Yes, you can allow multiple users to login. Codeigniter sessions are based on browser/ip/etc - not on username. So, you control the logic of the app and you can determine in your libraries and controllers if you allow multiple logins with the same username.
The other part of your question is also based on the logic of your app. You'll have to keep track of the CI sessions and add the usernames or other identifying information to the session with:
$this->session->set_userdata('username', 'userA');
Then, when userA clicks that upload button, you'll have to save that as well:
$this->session->set_userdata('upload_clicked', 'userA');
Then, for your other users, you'll have to query the ci_session database to see if userA has clicked that upload button to determine if you should show the button to the other users:
$results = $this->db->query("SELECT user_data FROM ci_sessions WHERE user_data LIKE '%upload_clicked%'");
// pseudo-code below:
// this will give you all the records with `upload_clicked` saved in user_data
// then loop through those results and unserialize user_data
// then check if upload_clicked == userA