Jump to content

etonB

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Everything posted by etonB

  1. I've talked with their tech support and they say the sessions settings on their end are good. Can anyone give me some input on the way I'm currently handling log-out?
  2. I'm going to look into that (hosting @ ipage) later on because I don't actually have access to php.ini But the thing is, the logouts aren't random as they always happen when I do the steps shown. Is my logout done correctly? I've read other advice like doing $SESSION = array(); instead of unset_session(); but I'm clueless.
  3. I'm making a small website where an admin has special functions. I've managed to make my login/logout scripts with sessions and able to show the admin's special functions only to him. The problem is when logging out and back in, it gets really weird. This is how I can come accross the error: 1. Enter my website 2. Log-in as 'admin' 3. Click on Add News (the special functions) 4. At this point, things work perfect, I can add news and go back to main page. 5. Log-out 6. Log-in as 'admin' again 7. Click on Add News 8. At this point, I get logged out and can't add news obviously until I log in again. This is how I perform log-out <p class="textoIngresar">Welcome, <?php echo $_SESSION["loggedUser"];?> ( <a href="index.php?action=logout">Log-out</a> )</p> This is the actual log out function if ( $_GET["action"] == "logout") { session_unset(); session_destroy(); } Am I doing the logout wrong? I need to know if that part is ok so I can look for errors elsewhere. Thanks in advance, etonB.
  4. It turns out this was a problem on the server's side. I talked with their tech support and they "set the session path for my account". My sessions work perfectly fine now. I will now mark this solved, thanks to StathisG and PFMaBiSmAd for their input on session_start() placement.
  5. I just re-tried and changed a bit of structure and the sessions now work when tested @ http://localhost However, when uploaded to the actual website (hosting with www.ipage.com, no php.ini access) the sessions are still not maintained. Is there a setting I must/can override in htacess in order to make sessions work? Should I start a different topic and mark this as solved since the problem is a bit different now?
  6. I don't mean to come off as stubborn here but I still don't quite get it. Is it not enough with adding an include(header.php) in every page if the header file has session_start() as it's first line?
  7. This is the first line of my header.php file: <?php session_start(); include('conexion.php'); ?> Is it bad to place session_start() on every page? Or will it simply be ignored? The sidebar is about the only part of the website that doesnt include(header.php), so when it calls itself on form submit I figured it wasn't starting the session correctly, so I thought I had to add session_start() on the sidebar itself as well.
  8. I've been trying to succesfully finish the Login part of my website to no avail. Everything works fine, and the user does get logged in right away, but the session is not maintained and I've ran out of ideas/help by googleing so I hope I can get a couple pointers here. Here's a bit of the code I'm using: <?php if ( !isset($_SESSION["username"]) ){ if ( !isset($_POST["frm_enviarLogin"]) ){ ?> <div class="avisoForm"></div> <form class="formLogin" id="form_Login" method="post" action="<?php echo $PHP_SELF;?>"> <input type="text" id="frm_username" name="frm_username" size="12" title="No mas de 12 caracteres"></input><label for="frm_username"> Username</label> <input type="password" id="frm_password" name="frm_password" size="12" title="No mas de 12 caracteres"></input><label for="frm_password"> ContraseƱa</label> <button type="submit" id="frm_enviarLogin" name="frm_enviarLogin">Entrar</button> <?php } else { if ( ($_POST["frm_username"] == "admin") && ($_POST["frm_password"] == "pass") ) { $_SESSION["username"] = "admin";?> <p class="textoIngresar">Bienvenido, <?php echo $_SESSION["username"];?></p> <?php } } } ?> Now, this code is placed in 'sidebar.php' and the thing is I have a 'header.php' on my website which is called with include (along with sidebar.php) from all of the diferent pages within the website. Where should I place session_start() for this to work? I've tried only adding it in 'header.php' but afaik it didn't work (the user gets logged in, but when moving to a different page the user is logged out now), and I've also tried placing session_start() everywhere, again with no results. I'm pretty sure I'm doing some newbie mistake here but I just can't see it. Thanks in advance, etonB.
×
×
  • 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.