lundi 28 décembre 2015

Check if session exists inside blade template - Laravel

Currently I have the below code in one of my vanilla php files

<?php 

if (isset($_SESSION['qwick'])) {
    include "checkout-lin.php";
} else {
    include "checkout-nlin.php";
}

?>

How can I do the same in laravel. I have created 2 files in my includes folder named loggedinclude.blade.php and notloggedinclude.blade and I now want to add them in a page checkstatus.blade.php

Also I'm able to set a session like this

$vars = [
    "email" => $email,
    "password" => $password,
    "firstname" => $row['firstName'],
    "lastname" => $row['lastName'],
    "id" => $row['id']
];

session()->put('blog', $vars);

As you can see I've given it a name blog... How can I check if this particular session exists in a controller..

FYI;

my first question is checking for session exist in blade

my second question is checking for named session exist in controller

The documentation only has code for checking session items

if ($request->session()->has('users')) {
    //
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Op58U2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire