Because...php.
string session_name ([ string $name ] )
Warning The session name can't consist of digits only, at least one letter must be present. Otherwise a new session id is generated every time.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I created this session to increment when ever a new session is declared. but it keeps read the if false because i saved the session name with an int instead of the key being using the name of the int which is 25, it starts from 0. but when i save the session name with a string, the session saves and works perfectly.
{
$id = $request->route('id');
$session_id = $id;
// $ba = 4;
// $foo = "four";
// $za = $session_id + $foo;
// dd($za);
if(Session()->exists($session_id))
{
return $next($request);
}
else{
$var = new post;
$var->viewcount_session($session_id);
$results = post::select('page_views')->find($id);
$results= ++$results->page_views;
$results= DB::table('posts')->where('id', $id)->update(['page_views' => $results]);
return $next($request);
}
public function viewcount_session($session_id){
$var = $session_id;
return $value = session([$var =>'car']);
redirect('/articles/{id}');
}
Because...php.
string session_name ([ string $name ] )
Warning The session name can't consist of digits only, at least one letter must be present. Otherwise a new session id is generated every time.
Please or to participate in this conversation.