Question: From the following data i want to get the MaxID of EmpID 1100

```
ID  | EmpId  
1   | 1002   
5   | 1100   
6   | 1109   
7   | 1100   
9   | 1100   
10  | 1250   
11  | 1250   
12  | 1100   

```

Results should be

```
ID
9  

```

Please help

Answer: 
You can store url inside a session may, $\_SESSION['visited\_page'] inside header. Every time user visit different url this session value updated. During logout, you can assign url inside $\_SESSION['visited\_page'] to $\_SESSION['last\_visited'] and unset $\_SESSION['visited\_page']. Now you have the url user last visit. I hope you get my point.
When redirecting in your logout function you could check the `last_visited` variable. Add it to the url you're redirecting to like so:

`$this->redirect("http://nostools.cz/content/login?last_visited=" . $last_visited );`

Then when you log in you check if `$_GET['last_visited']` is set, if it is then you redirect from your login to that page