Question: I have a PHP form that inputs empID, projectNumber, and clock-in/clock-out time-stamp into a MySQL table like this:

Having no reputation, I can't post image, so take a look here:
[screenshot http://mailed.in/timecard/ss1.jpg](http://mailed.in/timecard/ss1.jpg)

I need help in generating a report that looks like this:
[screenshot http://mailed.in/timecard/ss2.jpg](http://mailed.in/timecard/ss2.jpg)

Can I do this entirely in MySQL? How?

Answer: 
> 
> This confused me because I thought that one user only has a specific session, no one can access of the others. If so, session attributes are thread safe.
> 
> 
> 

Well, if that was the case, session attributes need not be thread-safe. That is different from saying they are thread-safe.

The lack of thread safety might be a problem if you have more than one thread handling the same user's session at the same time. Maybe some parallel executions that you spawned from the main request worker thread. Or the same user accessing the server more than once (such as loading five frames at the same time).
Session attribute is not `thread safe`.

From this document ([Java theory and practice: Are all stateful Web applications broken?](http://www.ibm.com/developerworks/library/j-jtp09238/index.html))

> 
> When a Web application stores mutable session data such as a shopping
>  cart in an HttpSession, it becomes possible that two requests may try
>  to access the shopping cart at the same time. Several failure modes
>  are possible, including: 
>    
> 1. An atomicity failure, where one thread is
>  updating multiple data items and another thread reads the data while
>  they are in an inconsistent state   
> 2. A visibility failure between a
>  reading thread and a writing thread, where one thread modifies the
>  cart but the other sees a stale or inconsistent state for the cart's
>  contents
> 
> 
> 

Have a look at thread from `coderanch`;

1. [How HttpSession is not thread safe](http://www.coderanch.com/t/361845/Servlets/java/HttpSession-not-thread-safe)
2. [Are Session thread safe.](http://www.coderanch.com/t/468616/Servlets/java/Session-thread-safe)