UserController.php
public function contactList(Request $request)
{
//after removing this if function. it is working
if ($request->session()->has('id')) {
$request->session()->flash('id', 0);
}
try {
....//Doing Something.
} catch(\PDOException $e){
...//Doing Something.
}
}
public function contactDetail(Request $request,$user_id)
{
try {
DB::connection()->getPdo();
try {
$id = User::findOrFail($user_id);
$request->session()->put('id', $user_id);
... //Doing Something.
} catch(\Exception $ex) {
... //Doing Something.
}
} catch(\PDOException $e) {
... //Doing Something.
}
}
public function sendMessage(Request $request)
{
// dd($request->session()->get('id'));
// dd($request->session()->has('id'));
if (!$request->session()->has('id')) {
return redirect()->to('/');
}
$rand = $this->generateRandomString(6);
return View::make('sendmessage')->with('random',$rand);
}
Functions are calling in above sequence but when calling sendMessage
function. value of session(id)
is showing null
. but calling contactDetail
function value of session(id) is 1
. why session(id) sending back null
value? . . . I'm getting stuck now.
Functions are calling in above sequence but when calling sendMessage
function. value of session(id)
is showing null
. but calling contactDetail
function value of session(id) is 1
. why session(id) sending back null
value? . . . I'm getting stuck now.
!session::get('id')
it is not returning false value. so replace if
& else
code with together.