Perad Posted June 5, 2007 Share Posted June 5, 2007 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 More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 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 https://forums.phpfreaks.com/topic/54296-registering-session-trouble/#findComment-268459 Share on other sites More sharing options...
trq Posted June 5, 2007 Share Posted June 5, 2007 Just to reiterate, session_regsiter() and its friends have LONG been depricated. Link to comment https://forums.phpfreaks.com/topic/54296-registering-session-trouble/#findComment-268466 Share on other sites More sharing options...
taith Posted June 5, 2007 Share Posted June 5, 2007 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 https://forums.phpfreaks.com/topic/54296-registering-session-trouble/#findComment-268467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.