This topic is locked
[SOLVED]

  Create session variable with value in URL after login

9/27/2013 2:46:55 PM
PHPRunner General questions
C
copper21 author

Hello,
I have a question regarding making a value in an URL into a session variable. I have application A that has a hyperlink into application B. Application A does not require you to login, but application B does. I use AD for authentication. When I click the link in application A, a new window pops up and if the user is not logged into application B (which is most of the time), they will be asked to login. Once the user successfully logs in, the user is then directed to an add page in application B using values in the URL. An example of the URL looks like this: http://webserver/application/application_add.php?ID=1234&FIELD=Bob'>http://webserver/application/application_add.php?ID=1234&FIELD=Bob. This works great.
Now I have a page redirect after successful login if the user does not have an email address in their user account. The application does redirect to the users account and makes them enter and save their email address if they do not have an email address in their account.
When the user clicks save, I would like them to be redirected to the original URL from application A: http://webserver/application/application_add.php?ID=1234&FIELD=Bob'>http://webserver/application/application_add.php?ID=1234&FIELD=Bob.
When a user does not have to enter their email address, I have this in the add page: before process and works well:
if (@$_REQUEST["ID"])
{

$_SESSION["ID"] = $_REQUEST["ID"];

}
if (@$_REQUEST["FIELD"])
{

$_SESSION["FIELD"] = $_REQUEST["FIELD"];

}
If a person has to enter their email first before proceeding to the add page, how do I keep the values of the URL values? Is there an event I can do in the login page to make them a session variable so I can use them or do I have to do something in the events of the page (account page) the user is directed to?
Thanks in advance,
Brian

Admin 9/27/2013

This is how it works by default. If user is trying to access one of internal pages of the application that requires login she will be redirected to that URL automatically after successful login. All you need to do is to remove your own redirect in AfterSuccessulLogin event.
Variable name where URL is stored: $_SESSION["MyURL"]

More info: http://xlinesoft.com/phprunner/docs/phprunner_session_variables.htm

C
copper21 author 9/27/2013

Thanks for the reply, yes I do understand that. I will try to explain better:
Login->Successful login->User has email in profile table->redirected to add page....that works as expected.
My dilemma:
Login->successful login->User DOESNT have email in profile table->Redirect to profile edit page-> enter email and click save-> NOW redirect to add page. (Here is where I need to somehow access those original values in the URL)
In order for user to add info on the add page, the user must have a valid email address in their profile. That is why a user has to be redirected to the user profile edit page before going to add page.
Thanks for all you do!

C
copper21 author 9/27/2013

Solved this one!
I placed the code:
$_SESSION["URL"] = $_SESSION["MyURL"];
In Login page: Before process and then added the code:
if($oldvalues["email"] == '' && $_SESSION["URL"])

{

header("Location: ".$_SESSION["URL"]."");

exit();

}
to the edit page (after record updated) of the account profile edit page if they needed to fill in email address. When the user finished filling out email address and clicks save, I am correctly taken to the add page.
Thanks for your guidance!
Brian