-2

My site sends email with a link to the user if the CO is finalized.

If the user is not signed in the user must first go to the login page, and only if user is signed in then they are redirected to the url.

Now if user is signed in they go to directly to the url, but not signed in go to log in page, he can log in but he is not direct to the url can anyone help with that?

this page url with some parameters is send to the user to as link

<?php
if(isset($_SESSION['ssid']) &&  $_SESSION['ssid'] == session_id() ) 
{ 
      // do you staff, after login confirm
}          
else { 
    // redirect to loginPage.php
}
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\widgets\Pjax;
use kartik\grid\GridView;
use backend\models\Item;
use backend\models\Respond;
use kartik\time\TimePicker;
use backend\models\RespondItem;
use backend\models\RequestItem;
use backend\models\DistributorHasItemCode;
?>
<?php
$check = null;
$checknow = null;
$checkfield = null;
$today = date('Y-m-d');
$date = date("Y-m-d H:i:s", time()); 
$date1 = new DateTime($date); 
$date2 = new DateTime($model->end_date.' '.$model->end_time);
if(empty($model->end_date))
{
    $model->end_date = $today;
}

if (Yii::$app->user->identity->ref_table =="sales_rep") 
{
    $sales_rep = Yii::$app->user->identity->ref_id;
    $respond = Respond::find()->where(['sales_rep_id'=>$sales_rep,'customer_order_request_id'=>$model->id])->one();

    if (!empty($respond) && $respond->status == 'Finalized and customer Notified' || $date1>=$date2 ) 
    {
        $check = "disabled='disabled'";
    }

    if ($model->status == 'Finalized and Sales Rep Notified') {
        $checknow = "disabled='disabled'";

    }

}else {
    if ($model->status == 'Finalized and Sales Rep Notified') {
        $check = "disabled='disabled'";
    }
}
?>
  <?= Yii::$app->session->getFlash('success') ?>
  <div class="customer-order-request-form">

<?php $form = ActiveForm::begin(['id'=>'cor']); ?> 

<fieldset <?= $check?> >
<fieldset <?= $checknow?> >
<div class="row">
    <div class="col-lg-4">

        <?= $form->field($model, 'code')->textInput(['maxlength' => 10,'readonly'=>TRUE]) ?>
    </div>
    <div class="col-lg-2" disabled>
    <?= $form->field($model, 'end_date')->widget(\yii\jui\DatePicker::classname(), [
            'dateFormat' => 'yyyy-MM-dd',
            'clientOptions'=> ['defaultDate'=>$today,'minDate' =>$today,],
            'options'=>[
                'class'=> 'form-control',

            ],
            ])
    ?>
    </div>
    <div class="col-lg-2">
        <?= $form->field($model, 'end_time')->widget(TimePicker::classname(), [
            'pluginOptions' =>
            [
                'showMeridian' => true,
            ],

            ]);
        ?>
    </div>

    <div class="col-lg-4">
        <?= $form->field($model, 'status')->textInput(['readonly'=>TRUE]) ?>

    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <?= $form->field($model, 'description')->textarea(['rows'=>3]);?>
    </div>
</div>
</fieldset>
<div class="form-group">
    <?= Html::submitButton((Yii::$app->user->identity->ref_table =="sales_rep")?'Save':'Update', ['class' =>'btn btn-success']) ?>
    <?= Html::button((Yii::$app->user->identity->ref_table =="sales_rep")?'Finalize & Notify Customer':'Finalize & Notify Sales Reps', ['class' => 'btn btn-primary finalize']) ?>
</div>

</fieldset>
<?php ActiveForm::end(); ?>

learnwhat
  • 177
  • 2
  • 15
  • 4
    Can you share us your code ? What have you tried so far ? – Nirnae Nov 04 '15 at 09:50
  • i will add url destination code. what you need to get idea abut problem? – learnwhat Nov 04 '15 at 09:53
  • 1
    https://stackoverflow.com/questions/33514216/how-to-redirect-user-to-particular-link-after-login-in-php/33514268#33514268 https://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php – Jameson Nov 04 '15 at 09:53
  • 1
    @learnwhat I surely already get what the problem is, but I need to know what you've tried to be sure that you dont just want us to lay some code like that :) and also to find a solution that fit your coding style as much as possible – Nirnae Nov 04 '15 at 09:58
  • You have been a member long enough to know **We are not clairvoyant** Please add some code to your question. Its does not have to be the real code but it must demonstrate the problem you are having. – RiggsFolly Nov 04 '15 at 10:02
  • it is yii2 application i think i try with header option but I can't think a way to get the link that in the email link to the page.. – learnwhat Nov 04 '15 at 10:04
  • **Code, code code** or we will just be guessing!!!! – RiggsFolly Nov 04 '15 at 10:05
  • It'ss not about trust man i dont understand what need to be add. – learnwhat Nov 04 '15 at 10:05
  • `i will add url destination code. what you need to get idea abut problem?` what do you mean by this ?? Explain. – Nana Partykar Nov 04 '15 at 10:11
  • what codes need to be add ?. – learnwhat Nov 04 '15 at 10:13
  • yep it is a yii2 application. – learnwhat Nov 04 '15 at 10:14

1 Answers1

0

Should use session to handle login.

Suppose your url is http://somedomain.com/somepage.php?token=some_tokan. So, at somepage.php, use session checking for login confirm like :

<?php 

   ob_start();
   session_start();  

   if(isset($_SESSION['ssid']) &&  $_SESSION['ssid'] == session_id() ) 
   { 
          // do your stuff, after login confirm
   }          
   else { 
        // redirect to loginPage.php
        // With "header('Location:yoururl'); for example
   }

And in loginPage.php, after successful login credentials, assign $_SESSION['ssid'] value like:

    ob_start();
    session_start();  
    //  if login credentials are verified.
    $_SESSION['ssid'] = session_id();
Nirnae
  • 1,315
  • 11
  • 23
Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33