Jump to content
Sign in to follow this  
C)zy

Session Destroy - Se Distruge Sesiunea..

Recommended Posts

Deci..am un script de login ...merge perfect , scriptul este :

<?php


require ('functions.php');

require ('config.php');




if(!isset($_SESSION['logat_utilizator'])) $_SESSION['logat_utilizator'] = 'Nu';

if(!session_is_registered(email))

{


 $conexiune = mysql_connect($_mysql_host,$_mysql_user,$_mysql_password) or die("a.Nu ma pot conecta la MySQL!");

 mysql_select_db($_mysql_db, $conexiune) or die("Nu gasesc baza de date");


if(!isset($_GET['actiune'])) $_GET['actiune'] = '';

switch($_GET['actiune'])

{

case '':

?>

<br><br>

  <form name="form" method="post" action="login.php?actiune=validare">

  <center>

  <table width="230" border="0">

    <tr>

      <td><font size="1" face="Verdana" color="#00000">» <strong>E-mail</strong></font></td>

      <td width="119">

        <input name="email" type="text" class="box">

      </td>

    </tr>

    <tr>

      <td><font size="1" face="Verdana" color="#00000">» <strong>Parola</strong></font></td>

      <td width="119">

	  <input name="parola" type="password" class="box">

	  </td>

    </tr>

	<tr>

	<td>

	  <input name="Login" type="submit" class="box" value="Login">

	</td>

	<td>

	  <font size="1" face="Verdana"><strong><a href="inregistrare.php">» Inregistreaza-te</a></strong></font></a></td>

	</table>

	</center>

	</form>

	<BR><BR>

  <?

break;


case 'validare':

$_SESSION['email'] = $_POST['email'];


if(($_POST['email'] == '') || ($_POST['parola'] == ''))

{

echo '<center>

<b><font size="1" face="Verdana" color="#ff0000"><BR><BR>Completeaza user-ul si parola<br> 

Apasati <a href="login.php">aici</a> pentru a va intoarce la pagina de logare</font></b>

	<META HTTP-EQUIV=Refresh CONTENT="1; URL=login.php"></center>';

}

else

{

$cerereSQL = "SELECT * FROM `utilizatori` WHERE email='".htmlentities($_POST['email'])."' AND parola='".md5($_POST['parola'])."'";

$rezultat = mysql_query($cerereSQL);

if(mysql_num_rows($rezultat) == 1)

{

  while($rand = mysql_fetch_array($rezultat))

  {

    session_register("email");

    session_register("parola");

$data = date('Y-m-d H:i:s');

$IP = $_SERVER['REMOTE_ADDR'];

$cerereSQL = 'UPDATE `utilizatori` SET Data="'.$data.'", IP="'.$IP.'" WHERE email="'.$_SESSION['email'].'"'; 

mysql_query($cerereSQL);

    echo '<center>

	<b><font size="1" face="Verdana" color="#ffc00"><BR><BR><BR>Va rugam asteptati ....</font></b><br><br>

	Vei fi redirectionat.

	<META HTTP-EQUIV=Refresh CONTENT="1; URL=utilizator.php"></center>';

  }

}

else

{

echo '<center>

<b><font size="1" face="Verdana" color="#ff0000">Datele introduse sunt incorecte<br> 

Apasati <a href="login.php">aici</a> pentru a va intoarce la pagina precedenta</font></b></center>';

}

}

break;

}

}

else

{

    echo '<center>

	<b><font size="1" face="Verdana" color="#00000">Va rugam asteptati ....</font></b>

	<META HTTP-EQUIV=Refresh CONTENT="0; URL=utilizator.php"></center>';

}


?>

Deci...am un panou lateral care imi arata cand ma loghez "bun venit "emailul " de la $_session . Problema este urmatoarea , dupa ce ramane pagina deschisa si incerc sa deschid alta pagina din site ( toate paginile contin session_start() } sesiunea se distruge si nu te mai arata logat...deci din moment ce sesiunea mea este pornita la inceput...si imi arata corect..si functioneaza...si daca as alege orice link de pe site sam erg pe el tot logat imi arata..asta la inceput , dar daca il las 1 minut..si dau pe orice link sesiunea se distruge...care poate fi problema?

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...