Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 87
Registered: ‎04-30-2013
My Device: 9220
My Carrier: Blackberry

Maintain my session in my application?

Hi all,

 

  My requirement is how and where to maintain the session in application. I below mention my requirements with details

 

 1. Onclick MyApps--> Enter to the login page--> Userid, Pasword(Got sessionid)-->First screen.

 2. if once move out or close my application without logout.--> onclick Myapps-->First screen(Directly calls first screen).

3. If logout my session-->Onclick MyApps--> Enter to the login page--> Userid, Pasword(Got sessionid)-->First screen.

 

how and where to maintain that session value in my apps. 

If any one get idea please let me know.

 

Thanks

Naresh

Developer
Posts: 19,633
Registered: ‎07-14-2008
My Device: Not Specified

Re: Maintain my session in my application?

Can't you just put the login state in some persistent place and check it when you start your application.

 

Search on here for additional information if the use of persistent storage is new to you.  Or use the java micro site:

http://developer.blackberry.com/bbos/java/documentation/overview_1981751_11.html

Highlighted
Regular Contributor
Posts: 66
Registered: ‎08-28-2010
My Device: 9630

Re: Maintain my session in my application?

Hi,

 

I agree with peter .  you can use the persistent storgae or database to store user record and login state.

 

Regards,

Regular Contributor
Posts: 87
Registered: ‎04-30-2013
My Device: 9220
My Carrier: Blackberry

Re: Maintain my session in my application?

Thanks for your reply.

Now i got the session and cookie value from my response and write these values in .txt file and stores in my simulator.

When i enters to my apps, read the value from .txt files and pass these values using my url and check the session in my server.

 

This way is correct to check the session?

But still i didnt get response from server side.

 

 

 

 

Regular Contributor
Posts: 66
Registered: ‎08-28-2010
My Device: 9630

Re: Maintain my session in my application?

hi,

 

once you close your app your session will be expire. you need to create the new session.

 

For new session you can pass your user data from text file and verify connect with server.

 

Also verify server create and allow new session with existing user.

 

Regards,

Regular Contributor
Posts: 87
Registered: ‎04-30-2013
My Device: 9220
My Carrier: Blackberry

Re: Maintain my session in my application?

ya.. exactly..  

i will check with session and user identity number in database. 

I saved and update the .txt files in file:///System/device/User/Test.txt

 

Regular Contributor
Posts: 87
Registered: ‎04-30-2013
My Device: 9220
My Carrier: Blackberry

Re: Maintain my session in my application?

Plz let me know ia am doing any mistake in this way.

 

 

Developer
Posts: 19,633
Registered: ‎07-14-2008
My Device: Not Specified

Re: Maintain my session in my application?

"This way is correct to check the session?"

 

Whether it is or not will depend on the way your Server handles the sessions and tokens. So you need to research that and understand what the Server expects. 

 

Because http is a 'stateless' protocol, the state of the session has to be maintained externally, and how this is done will depend on the way the Server has been designed. Where the Server application supports a application interface, the Server will normally return a token - this token will be all you need to confirm the user has logged in.  But this token might have a limited life, or you can 'log-out' - in either case the Server application removes the token and it can not be used again. But in this situation, as long as you are within time, your application can continue to use the token.  So it is possible for you to store the token, however you want, and recover it for use later, even if your application has been stopped and started. 

 

If you try to use a token once it has 'expired', the Server application will usually return an error message that indicates you are not logged in. 

 

"Plz let me know ia am doing any mistake in this way."

 

We can't answer this question, because it depends on the Server application.  I think what you are doing will work for some applications, but may not work for the one you are are trying to connect to.