Reputation: 23690
I want to whip together an application for the Windows Phone 7 for my existing website.
At the moment my SESSIONs
are handled by PHP, but I haven't a clue how sessions would be handled using a Windows Phone 7
application.
I'm not even sure how I would conduct a login from the app, because I will need to send the username/password in some secure manner.
At the moment I store a SESSION id in the database to determine if the user is still active.
I would like to gain some insight in to how this can be achieved.
Upvotes: 0
Views: 677
Reputation: 50602
The concept of a session, in the context of PHP and web applications, is a relationship between the server and the client. The most common scenario is a browser requesting a web site.
In this process, the server establishes a unique session ID. By default, PHP uses cookie data to store that unique ID; this allows it to determine in subsequent requests that a known client (one who has established a session) is accessing the server. PHP uses the hash stored in that specific cookie (the cookie is called PHPSESSID by default) to re-associate any session data with that request.
I explain this because you seem to have a misconception about what sessions are - PHP doesn't care that the user agent is on the Windows 7 phone platform, a browser, or any other user agent. If the user agent supports the cookie mechanism configured in php.ini (see second option below), then you may have sessions. Further, sessions are not the purview of the client; the client doesn't know about them or need to know about them (exceptions might apply in some use cases). The server generally manages the relationship between the client and the server, and session-bound data established on the server-side is not available to the client unless made explicitly so.
So, you're faced with two options. First, you can support cookies in your C# application. Look in to the HttpCookie
class (docs), and understand how cookies work. Depending on the way you're building your application and the mechanism by which you're initiating outbound requests, you may have support cookies baked right in.
Second option is to use a different mechanism for tracking session. PHP supports passing a session ID via the URL, however there are security considerations that apply. See the documentation.
Upvotes: 2