简体   繁体   中英

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?

$_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

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();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM