I want to save the sessionID or SessionHash to get the corresponding user. But I have tried these two ways but they are not working.
This way the error is in line 16
This way session is null
Help me to use session ???
Re: Help me to use session ???
Hi,
I am not sure why you would want to "save" those values. They only exist for the duration of the user's session, so they are already "saved" in the sense that you can access them at any time, given the User object.
Can you better explain?
thanks
I am not sure why you would want to "save" those values. They only exist for the duration of the user's session, so they are already "saved" in the sense that you can access them at any time, given the User object.
Can you better explain?
thanks
Re: Help me to use session ???
Lapo wrote:Hi,
I am not sure why you would want to "save" those values. They only exist for the duration of the user's session, so they are already "saved" in the sense that you can access them at any time, given the User object.
Can you better explain?
thanks
I'm wondering why I can not use the function getSessionByHash () and the getSessionById ()?
Re: Help me to use session ???
Please take a look at my code. Where "user" is the current user request to server
Re: Help me to use session ???
I am sorry but the code you have posted makes very little sense.
You already have the User object and you're writing 4 lines of code to obtain the same user object? Why?
If you have a User object and you need its session, the just use
Other than that you should never need to mess with Sessions in your code. That's low level stuff that is not useful for implementing the game logic. On the other hand if you mess with its state you may cause problems.
If you have a specific use case then please explain.
In the second example you're trying to obtain a Session via it's ID but you're passing the Session's hash which is not the same thing.
The ID is a numeric value, the hash is a String.
As I said, Sessions are managed for you so you can concentrate on your game logic, instead of dealing with lower level stuff. If I have misunderstood then clarify what's the purpose of this.
Thanks
You already have the User object and you're writing 4 lines of code to obtain the same user object? Why?
If you have a User object and you need its session, the just use
Code: Select all
user.getSession()
Other than that you should never need to mess with Sessions in your code. That's low level stuff that is not useful for implementing the game logic. On the other hand if you mess with its state you may cause problems.
If you have a specific use case then please explain.
In the second example you're trying to obtain a Session via it's ID but you're passing the Session's hash which is not the same thing.
The ID is a numeric value, the hash is a String.
As I said, Sessions are managed for you so you can concentrate on your game logic, instead of dealing with lower level stuff. If I have misunderstood then clarify what's the purpose of this.
Thanks
Who is online
Users browsing this forum: No registered users and 96 guests