Jump to content

Registering session trouble?


Perad

Recommended Posts

Is anything wrong with the code below. I was pretty sure that this was working earlier today and just wanted to make sure that the code below is registering a session to those who don't have one before i sift through the other 500 lines of code.

 

session_start();
if(session_is_registered("user_logged_in")){
     
} else {
session_register(user_logged_in);
$_SESSION['user_id'] = $row['user_id'];	
$_SESSION['profile'] = "Bigs";
$_SESSION['acc_lvl'] = "-1";
$_SESSION['login'] = FALSE;
$_SESSION['user'] = "Guest";
}

Link to comment
https://forums.phpfreaks.com/topic/54296-registering-session-trouble/
Share on other sites

Caution

 

If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister().

 

I do not think you need to use session_register at all, try this out instead:

 

<?php
session_start();
if(!isset($_SESSION['user_logged_in'])) {
$_SESSION['user_logged_in'] = true;
$_SESSION['user_id'] = $row['user_id'];	
$_SESSION['profile'] = "Bigs";
$_SESSION['acc_lvl'] = "-1";
$_SESSION['login'] = FALSE;
$_SESSION['user'] = "Guest";
}
?>

 

That should work.

Just to reiterate, session_regsiter() and its friends have LONG been depricated.

 

for those of use without a huge vocabulary...

 

session_regsiter()/session_is_regsitered() are not necessary anymore...

 

session_start();
if($_SESSION[user_logged_in]!==true){
$_SESSION[user_logged_in]=true;l
$_SESSION['user_id'] = $row['user_id'];	
$_SESSION['profile'] = "Bigs";
$_SESSION['acc_lvl'] = "-1";
$_SESSION['login'] = FALSE;
$_SESSION['user'] = "Guest";
}else{
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.