jason360 Posted July 5, 2012 Share Posted July 5, 2012 Hey guys, I have a login system that welcomes the user with their first name. The system is working however it will not display the name when I log in with cookies, however the print_r array for cookies is showing that the 'first' name is working. I am hacking away trial and error but not sure how to do this. I tried various combos. My cookie is $COOKIE['first'] My code is as follows: <div class="tab"> <ul class="login"> <li class="left"> </li> <li>Hello <?php echo $_SESSION['first'] ? $_SESSION['first']: 'Guest';?>!</li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#"><?php echo $_SESSION['user_id']?'Open Panel':'Log In | Register';?></a> <a id="close" style="display: none;" class="close" href="#">Close Panel</a> </li> <li class="right"> </li> </ul> </div> <!-- / top --> Thanks again! JK Link to comment https://forums.phpfreaks.com/topic/265227-php-session-and-cookies-array/ Share on other sites More sharing options...
jason360 Posted July 5, 2012 Author Share Posted July 5, 2012 Just in addition to the above: Would including cookies to this statement: if(!$_SESSION['user_id']): be done like this?: if((!$_SESSION['user_id'])||(!$_COOKIE['user_id'])): Link to comment https://forums.phpfreaks.com/topic/265227-php-session-and-cookies-array/#findComment-1359239 Share on other sites More sharing options...
requinix Posted July 5, 2012 Share Posted July 5, 2012 Your "login" process has to check for a cookie and, if present and valid, use that to populate information in the session. Besides that code you don't really have to care about cookies. Link to comment https://forums.phpfreaks.com/topic/265227-php-session-and-cookies-array/#findComment-1359258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.