<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[set-cookie]]></title><description><![CDATA[<p dir="auto">ciao a tutti,<br />
ho creato questa area di login funzionante con la pagina di registrazione ed ovviamente mysql. il problema è che vorrei trovare il tag cookie per tener loggato un utente, ad esempio per...........una settimana. qualcuno mi puo aiutare? grazie.<br />
questa è la pagina di login:</p>
<p dir="auto">&lt;form id="form1" name="login" method="POST" action="index.php"&gt;<br />
&lt;fieldset&gt;<br />
&lt;legend&gt;&lt;strong&gt;Login&lt;/strong&gt;&lt;/legend&gt;<br />
&lt;p&gt;<br />
&lt;label for="username"&gt;&lt;strong&gt;Username&lt;/strong&gt;&lt;/label&gt;<br />
&lt;input type="text" name="username" id="username" /&gt;<br />
&lt;label for="password"&gt;&lt;strong&gt;&lt;br /&gt;<br />
&lt;br /&gt;<br />
Password&lt;/strong&gt;&lt;/label&gt;<br />
&lt;input type="password" name="password" id="password" /&gt;<br />
&lt;/p&gt;<br />
&lt;p&gt;<br />
&lt;label for="invio"&gt;&lt;/label&gt;<br />
&lt;input type="submit" name="invio" id="invio" value="Accedi" /&gt;<br />
&lt;/p&gt;<br />
&lt;p&gt;&lt;a href="registrazione.php"&gt;Registrami&lt;/a&gt;&lt;br /&gt;<br />
&lt;/p&gt;<br />
&lt;?php require_once('Connections/connectdw.php'); ?&gt;<br />
&lt;?php<br />
if (!function_exists("GetSQLValueString")) {<br />
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")<br />
{<br />
if (PHP_VERSION &lt; 6) {<br />
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br />
}</p>
<p dir="auto">$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);</p>
<p dir="auto">switch ($theType) {<br />
case "text":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "long":<br />
case "int":<br />
$theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />
break;<br />
case "double":<br />
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";<br />
break;<br />
case "date":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "defined":<br />
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />
break;<br />
}<br />
return $theValue;<br />
}<br />
}<br />
?&gt;<br />
&lt;?php<br />
// *** Validate request to login to this site.<br />
if (!isset($_SESSION)) {<br />
session_start();</p>
<p dir="auto">}</p>
<p dir="auto">$loginFormAction = $_SERVER['PHP_SELF'];<br />
if (isset($_GET['accesscheck'])) {<br />
$_SESSION['PrevUrl'] = $_GET['accesscheck'];<br />
}</p>
<p dir="auto">if (isset($_POST['username'])) {<br />
$loginUsername=$_POST['username'];<br />
$password=$_POST['password'];<br />
$MM_fldUserAuthorization = "";<br />
$MM_redirectLoginSuccess = "home.php";<br />
$MM_redirectLoginFailed = "index.php";<br />
$MM_redirecttoReferrer = false;<br />
mysql_select_db($database_connectdw, $connectdw);</p>
<p dir="auto">$LoginRS__query=sprintf("SELECT username, password FROM utenti WHERE username=%s AND password=%s",<br />
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));</p>
<p dir="auto">$LoginRS = mysql_query($LoginRS__query, $connectdw) or die(mysql_error());<br />
$loginFoundUser = mysql_num_rows($LoginRS);<br />
if ($loginFoundUser) {<br />
$loginStrGroup = "";</p>
<pre><code>if (PHP_VERSION &gt;= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
</code></pre>
<p dir="auto">//immagazzinano le informazioni dell'utente in un array</p>
<pre><code>    $var_session["username"]=$row["username"];
    $var_session["password"]=$row["password"];

    //setto la durata del cookies a una settimana
    $time_cookie=3600*24*7;
    setcookie("session", $var_session["username"].'_&amp;&amp;_'.$var_session["password"], time()+$time_cookie);

header("Location: " . $MM_redirectLoginSuccess );
</code></pre>
<p dir="auto">}<br />
else {</p>
<p dir="auto">echo "Non hai inserito i dati corretti. Riprova.";</p>
<p dir="auto">}<br />
}<br />
?&gt;&lt;br /&gt;<br />
&lt;/fieldset&gt;<br />
&lt;/form&gt;</p>
]]></description><link>https://dev.connect.gt/topic/154990/set-cookie</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 13:25:21 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/154990.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Jul 2011 11:57:24 GMT</pubDate><ttl>60</ttl></channel></rss>