Either the data is secure or insecure, it does not really matter if the data is stored in two separate Session
objects or not. So if user ID or nickname can be used maliciously by someone, then it is is insecure; otherwise not.
I generally store user information in a single Session
object named something like LoggedOnUser
, which represents an instance of a class. In your case, it might be overkill to create a class to hold just two pieces of information.
I would advise against using nickname solely as a URL, because what if the nickname
value changes? User ID seems more appropriate, as that is less likely to change, if ever. This is how StackOverflow does it with your user profile (stackoverflow.com/users/YOUR_USER_ID/YOUR_NICKNAME
), if you have previous nicknames, then the old nicknames will map to the current nickname, based upon your user ID value.