troubleshooting Question

How does one establish a quick and easy session variable in Laravel?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
2 Comments2 Solutions27 ViewsLast Modified:
Here's the code in my Controller:

      public function practice($id) {
            $practice = practice_video::findOrFail($id);
            return view('practice', compact('practice'));            

This syntax will give my user this screen:


Thing is, I need to protect this page with a login dynamic. In other words, my user has to first login using their email and a predetermined password.

Having seen the "magic" of Laravel's "auth" dynamic, I didn't want to start from scratch using Vanilla PHP if there was quick and easy way to set up a login page that would establish a session variable that could be checked by the above page before it displayed the video.

How does one do that in the context of Laravel?

Here's the blade for the above page:

<!-- Section: intro -->
<section id="intro" class="intro">
	<div class="satellite-content">
		<div class="container">
			<div class="row">
				<div class="col-xs-12 satellite_row">
					Hello, {{$practice->first_name }} {{ $practice->last_name }}!
					Below you'll find the "practice video, "<b> 
					@if($practice->clip==1 || $practice->clip==2 || $practice->clip==3 || $practice->clip==4 || $practice->clip==5 || $practice->clip==6 || $practice->clip==7 || $practice->clip==8 || $practice->clip==9 || $practice->clip==10)
					You'll have access to this video until <b><?php echo date("m/d/Y", strtotime($practice->expiration_date));?></b>. If you have any questions, contact NOMAS International by clicking <a href="/contact">here</a>.
					<div style="padding:10px; border:1px solid #ccc; text-align:center;">
						<div class="embed-responsive embed-responsive-16by9">
							<iframe class="embed-responsive-item" src="{{ asset('assets/videos/video_'.$practice->clip.'.mp4') }}" allowfullscreen autoplay=false></iframe>

Open in new window

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros