本文整理汇总了PHP中App\Http\Controllers\Session::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getId方法的具体用法?PHP Session::getId怎么用?PHP Session::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Session
的用法示例。
在下文中一共展示了Session::getId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkLogin
public function checkLogin(Request $request)
{
$key = $request->input('key');
$user = DB::table('users')->where('keypass', $key)->first();
//$results = app('db')->select("SELECT * FROM user");
$requestStation = "";
if ($request->session()->has('requestStation')) {
$requestStation = $request->session()->get('requestStation');
}
$result = array('login' => 'error', 'code' => 0, 'url' => $requestStation);
if ($user) {
$new_sessid = \Session::getId();
//get new session_id after user sign in
if ($user->lastSessionId != null) {
$last_session = \Session::getHandler()->read($user->lastSessionId);
// retrive last session
if ($last_session) {
if (\Session::getHandler()->destroy($user->lastSessionId)) {
}
}
}
DB::update('update users set lastSessionId = :lastSessionId where id = :id', ['lastSessionId' => $new_sessid, 'id' => $user->id]);
$request->session()->put('group', $user->group);
$request->session()->put('id', $user->id);
$request->session()->put('login', true);
$result['login'] = 'success';
$result['code'] = '1';
$result['session'] = \Session::getId();
}
return response()->json($result);
}
示例2: getAdd
/**
* Display the specified resource.
* add item in cart
* @param int $id
* @return Response
*/
public function getAdd($id)
{
$product = Product::find($id);
$product->view += 1;
$product->save();
$temp = ['id' => $product->id, 'name' => $product->name, 'category_id' => $product->category_id, 'qty' => 1, 'price' => $product->price, 'amount' => $product->price * (100 - $product->discount) / 100, 'discount' => $product->discount, 'image' => $product->image];
$data = \Session::get('giohang');
if (is_null($data)) {
$data[$product->id] = $temp;
//gan Key=$product->id =>value=$temp.
} else {
if (isset($data[$product->id])) {
$data[$product->id]['qty'] += 1;
$data[$product->id]['amount'] = $data[$product->id]['qty'] * $data[$product->id]['price'] * (100 - $data[$product->id]['discount']) / 100;
} else {
$data[$product->id] = $temp;
}
}
\Session::put('giohang', $data);
$data = \Session::get('giohang');
echo '<pre>';
print_r($data);
$id = \Session::getId();
echo '<pre>';
print_r($id);
// $id_new = \Session::setId('123');
// \Session::save();
// echo '<pre>';
// print_r($id_new);
//return redirect()->route('index');
// echo '<pre>';
// print_r(\Session::get('giohang'));
//\Session::forget('giohang');
}