How to handle session? When do we create a session id
<p>Hi all im facing a problem, and i need suggestion from the experts out here.
There is Shopping  cart module in my project that uses webservice .The workflow is </p>

<ol>
<li>Create session Id.( I have an xml input which returns me a long string as session id)</li>
<li>Add Product to cart ( WHere i use the above session id  and the product unique code as xm input)</li>
<li>Get cart ( Here the input parameter in the xml is the sessionid.Means i will get a list product in that session)</li>
<li>Delete from cart( Here the xml parameters are session id and product unique code)</li>
</ol>

<p>What i have done is while loading the splash screen i have written code to generate the session id and i keep it in  the first location of a list for later use.</p>

<pre><code>    CartService cartService=new CartServiceImpl();
    SterviceResponse ob = cartService.createPartnerSession();
    Session session = new Session();
    session.setSessionId(ob.getStringValue());
</code></pre>

<p>Session.getSessionId() will return me the session id
The program works fine if there is no internet problem,But if i switch off wifi in between the program will crash.Now i will have to restart the app to start a new session.Also i want to expire the session if the phone is idle for a particular period of time.</p>

<p>What is the best way to store and handle session id in side the program?</p>
