views:

305

answers:

1

As the title said, login page should be in flash(login.swf), and the redirect to a php page (account.php). In account.php, I will need to check session, for example:

isset($_SESSION['loggedin']){
  echo "Welcome back, $user";
} else {
  echo "You need to login and main site";
}

Where do I generate the sessions, and where do I store it, and how do I do the session check??

EDIT: About my current problems

  • Login in swf page
  • user type username and password and send to authenticate.php
  • if its valid user, i send variables back to flash: echo "login=true" and then start and create session e.g $_SESSION['username']
  • Back to flash, after some animation going, I click a button that link to profile.php page
  • In profile.php, i do a check if(isset($_SESSION['username']){ echo "welcome back user";
  • But the problem is, after i login in flash/swf page, i click the button to the profile.php page, I still need to login again, means, there is no $_SESSION['username'].

So, my questions: Where do I generate the sessions, and where do I store it, and how do I do the session check??

A: 

In the login.swf, on login button click, you need to do a http request to the server (say to validate.php page)with the credentials that user entered. In the validate.php you need to check for whether credentials are valid and need to create session if its valid and send back the response to the login.swf(in some xml format telling user is authenticated/valid or not).

On response handler of http request, get the result xml check whether user valid or not, if not valid show error message, if valid, call a javascript function(basically window.location.href='/account.php') which will redirect the entire page to account.php. Once the page request for account.php comes, you can use the session that you created and the user details from session.

Umesh
Thanks for you answer. After authenticate user, i need to show animation, and the click "a button" to the profile page, its not auto-redirect. I have done up all that you answered. My problem is at the profile.php, I need to do another login, thats mean, users always need to login twice, to access the profile page
blueredgreed
"users always need to login twice, to access the profile page" Is it a rule that you are following or its a problem and you dont it to happen?.if its somehting that you are trying to do, do something like this.You can access js variables from swf. Try to put some different values in login.php and profile.php and after response process get this variable and if its login page, show animation else go to profile page
Umesh
need to do something in login page before sending variables back to flash echo "login=true" .session_start(); $_SESSION['username'] = // store user name session and in profile.php $_SESSION['username']; //retrieve data This should work
Umesh