Using PHP sessions with my android application to login
Android Login and Registration are very common scenarios. You will find registration and login operation in all the apps where we want user information. In this tutorial, we’ll set up a local web server and MySQL database. We will develop android login and registration application. We will use PHP script to connect to the MySQL database.
Your login credentials are verified, and the server creates a session with a session ID for you. This session is stored in the database. Your session ID is stored in your browser (client) as a cookie. Upon subsequent requests, your cookie is verified against the session ID stored in the server.
One way is to make your php or any scripting language code echo a string containing the session_id in its response to login.Let the android app retrieve this id and store it. Any future requests can be made by using post method with sess_id=stored id
<?php
if(isset($_POST['sess_id']))
{
session_id($_POST['sess_id']); //starts session with given session id
session_start();
$_SESSION['count']++;
}
else {
session_start(); //starts a new session
$_SESSION['count']=0;
}
echo session_id();
?>
Post a Comment
0Comments