interstellar
interstellar

Reputation: 25

I want to insert my session variable value in the database.

I want to insert my session variable value in the database. i have tried this code but its not working
$uid=$_SESSION['userid'];
$image->U_id = Input::get($uid); what should i do?

Upvotes: 0

Views: 53

Answers (3)

Rinon
Rinon

Reputation: 579

I don't know what your aim is to achieve with this, but you can also store the sessions in the database with very little configuration if that's what you're after, Laravel already supports this.

Source

Upvotes: 0

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26258

$_SESSION['userid']; doesn't work in Laravel.

Try this:

$userid = Session::get('userid'); // this is the way to get laravel session value
// save it in database

Upvotes: 1

Mathias_
Mathias_

Reputation: 323

If you already have the variable stored in $uid, there is no reason to call Input::get().

So just do something likes this.

$uid=$_SESSION['userid'];

$image = new Image;
$image->U_id = $uid;

$image->save();

Upvotes: 0

Related Questions