[Solved] how to print user related data  

  RSS

arvind
(@arvind)
Active Member
Joined: 2 months ago
Posts: 8
31/03/2019 3:54 pm  

I want to show the details of current logged user like user details and user device list etc.

if possible give me an example.


Quote
jaimzj
(@jaimzj)
Guru Admin
Joined: 11 months ago
Posts: 46
31/03/2019 4:12 pm  

Arvind, first step always will be for you to try. have you tried?

Have you checked the examples in github? first try those then let me know wherever you get stuck.

Markers & maps are magical !!!


ReplyQuote
arvind
(@arvind)
Active Member
Joined: 2 months ago
Posts: 8
01/04/2019 6:15 am  

I tried but i had no luck. I logged through api and i am also able to register but i have no idea how to show current logged user detail and related devices.


ReplyQuote
jaimzj
(@jaimzj)
Guru Admin
Joined: 11 months ago
Posts: 46
01/04/2019 11:51 am  

In that case show me what you have tried so far to display user data.

Login and signup examples are right there, so it shouldn't have been a problem to achieve that anyway.

If you want me to help, you will need to share with me more information on how much effort and work you did on it, and exactly where you are stuck.

And If i see that for sure I will help. So share your code the parts where you say you tried and it did not work. and how you tried?

This post was modified 2 months ago by jaimzj

Markers & maps are magical !!!


ReplyQuote
abahaudd
(@abahaudd)
Active Member
Joined: 2 months ago
Posts: 8
01/04/2019 7:55 pm  

I am using laravel framework, so the way I set Session variable would be a bit different if you are not using that framework.  The concepts should work.  Sample code is attached.  With this code index Controller would log you in and display users.

public function index(Request $request)
{
if (!$request->session()->has('sessionId'))
{
$ret = Gps::loginAdmin();
$sessionId = Gps::$cookie;
$request->session()->put('sessionId', $sessionId);
$response = $ret->response;
$responseCode = $ret->responseCode;
}
else
{
echo "session is active";
}

$users = Gps::users($request->session()->get('sessionId'),2);
print_r($users);
}

However if you do not want to display 'devices' in a different function - 

public function show(Request $request)
{

// * check if a session exists

if( null !== $request->session()->get('sessionId')){

// * Get devices
$devices = Gps::devices($request->session()->get('sessionId'),1);
print_r($devices);
}
else
{

// * Display error and exit
echo "Not authorized";
}

}

I guess you get the concept.  


ReplyQuote
jaimzj
(@jaimzj)
Guru Admin
Joined: 11 months ago
Posts: 46
01/04/2019 9:45 pm  

Okay so @arvind started this topic and the last post is by @abahaudd with code samples.

Are both of you the same? if so please stick to using 1 user ID ! so that its easier for me to recognize your question and help you better. 

For this one time, I shall answer the question.

answering @abahaudd post 

What are you looking to solve in the code you shared?

what is the output of this part of your code.

$users = Gps::users($request->session()->get('sessionId'),2);
print_r($users);

 

Markers & maps are magical !!!


ReplyQuote
abahaudd
(@abahaudd)
Active Member
Joined: 2 months ago
Posts: 8
13/04/2019 6:13 pm  

Hi Jaimzj ... we are two different people.  I was just telling @arvind how I solved the problem.  

$users = Gps::users($request->session()->get('sessionId'),2);
print_r($users);

It gave me expected results -  details of user with id=2


ReplyQuote
jaimzj
(@jaimzj)
Guru Admin
Joined: 11 months ago
Posts: 46
14/04/2019 12:27 am  

oh cool, thank you for clarifying @abahaudd 

Markers & maps are magical !!!


ReplyQuote
Share:
  
Working

Please Login or Register