0

I am using this command to post parameters to my server :

response = CustomHttpClient.executeHttpPost("http://192.168.1.102/liu/login.php", postParameters);

When I get a successful log in from the server, my Android application is set to request the members.php page in webview, but when this happens I am redirected to the log in page to log in again, this means that the session has been dropped somewhere, so how do I maintain the session between the two requests ?

Here is the code on server side login.php:

 if($numrow!=0)
{
    while($row = mysql_fetch_assoc($query))
    {
        $db_username = $row['username'];
        $db_password = $row['password'];
    }

    if($username==$db_username&&$password==$db_password)
    {

        $_SESSION['username']=$db_username;
        header("Location: members.php");
        members area</a>";


    }

and members.php:

if($_SESSION['username'])
 {
echo "1";
echo "the logged in session is :". $_SESSION['username'];
echo " You are logged in as: ".$_SESSION['username'];

echo "<p><a href='logout.php'>Click here to logout</a>";
  }

Now this code works when I log in from my pc browser but when I send the info from the Android application and get successful reply then request the members.php page it takes me back to the log in.

1
  • Session parameters reside on the server. You don't have to pass them to mantain the session opened. If a session is already closed, that session id will be invalid. Commented May 27, 2012 at 22:33

2 Answers 2

2

you can refer to this link : Maintaining session in android ( application stay authenticated on the server side)

where i have mentioned how can we manage the session in android .

Try to take help from this.

Sign up to request clarification or add additional context in comments.

Comments

0

You should use GET parameters. PHP's format is

myscript.php?session_name=SESSION_ID

Be aware though, that this might not be enabled on your PHP server. Docs about passing the session ID

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.