Saving data between sessions

This is a discussion on Saving data between sessions within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Is it possible to save session values between pages? I did a little script to let the users login. I ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-24-2004
Lamp
 
Posts: n/a
Default Saving data between sessions

Is it possible to save session values between pages? I did a little script
to let the users login. I use this script to check username and password the
user introduces in a form in the main page, index.php.
If a user is found with username and password, than I create
$_SESSION['Login'] and assign it a value of true, else I assign it a value
of false. If a user is non registered, I send it to the proper page to
register, RegistraUtente.php, if he is registered yet, I send him back to
index.php
But here in index.php $_SESSION['Login'] has no value.

Here is the script I wrote:

<?php

session_start();

include("dbconnect.php");

$tabella="table";

$dbname="Zucca";

if (!isset($_SESSION['Login']))

{

$_SESSION['Login']=false;

}

$IdUser=session_id();

$data=date('Y-m-d');

if (!ISSET($HTTP_COOKIE_VARS["PiOnLine"]))

setcookie("PiOnLine",$IdUser,time()+60*60*24*365);

else

$IdUser=$HTTP_COOKIE_VARS["PiOnLine"];

mysql_select_db($dbname,$db);

$username=$_POST["username"];

$password=$_POST["password"];

$query="Select Username, UserPassword from $tabella where
('$password'=UserPassword) and ('$username'=Username)";

$result=mysql_query("$query") or die(mysql_error());

// Se esiste l'utente con username e password allora consenti il login

if (mysql_num_rows($result)==1)

{

$_SESSION['Login']=true;

session_write_close();

$url="index.php";

header ("Location: $url");

}

else // Invia l'utente sulla pagina di registrazione

{

$_SESSION['Login']=false;

session_write_close();

$url="RegistraUtente.php";

header ("Location: $url");

}

?>


Franz




Reply With Quote
  #2 (permalink)  
Old 04-25-2004
lamp
 
Posts: n/a
Default Re: Saving data between sessions

Well, I have solved the problem. In Windows you must specify a directory
where to save sessions. I dind't know that, in Linux I never did it, I
believe it was set by default.

Thanks

Franz
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:19 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0