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
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.

Link to comment
Share on other sites

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{
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.