Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Session problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 21.06.2005 19:56    Post subject: Session problem Add user to your forum ignore list Reply with quote

Ako moze ko pomoc...

Ovo je moj code , radim nekakav sustav registracije :

Code:

 session_start();
 session_name("id");
 session_cache_expire(15);
 
if (!$id)
{

 $id = session_id(md5(uniqid(rand(), true)));
 session_register("$id");

}

else {

    $id = session_id("$id");
   
   // 0dio   
   $_SESSION['plan']      = '$plan';
   $_SESSION['os']        = '$os';
   
   // 1dio
   $_SESSION['domenat']   = $_GET['domain'];
   
   // 2dio
   $_SESSION['domena']    = '$domena';
    $_SESSION['period']    = '$period';
   $_SESSION['nacin']     = '$nacin';
   $_SESSION['ime']       = '$ime';
   $_SESSION['org']       = '$org';
   $_SESSION['mb']        = '$mb';
   $_SESSION['adresa']    = '$adresa';
   $_SESSION['posta']     = '$posta';
   $_SESSION['grad']      = '$grad';
   $_SESSION['tel']       = '$telefon';
   $_SESSION['mob']       = '$mobitel';
   $_SESSION['email']     = '$email';
   $_SESSION['kako']      = '$kako';
   $_SESSION['napomena']  = '$napomena';
   
   // IP adresa
   $_SESSION['enduserip'] = $REMOTE_ADDR;
   $enduserip = $_SESSION['enduserip'];
}
   

?>


I sad... neradi.... mislim npr... uzmem 0dio.php u kojem se sadrži nekakva informacija o nekakvom "hosting planu" i dam mu id i sve i pošaljem na temp.php stranicu i tamo umjesto inforacije pritisnute na 0dio.php on meni samo ispise varijablu $plan....

Što da radim , jel mi uredu ovaj session_control ? mislim... pomagajte...[/quote]

_________________
have fun
Back to top
View user's profile Send private message
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 23.06.2005 10:34    Post subject: Add user to your forum ignore list Reply with quote

Ovo defintivino nece raditi kako ocekujes:
Code:
$_SESSION['email'] = '$email';

Naime, to u session varijablu 'email' stavlja string '$email', a ne vrijednost varijable $email. Ne trebaju ti single quoteovi s desne strane, pogotovo ako samo radis pridruizvanje druge vrijednosti neke druge varijable...

Ove ostale varijable dolaze getom, postom, kako? Ako ih ocekujes kroz neki request, probaj im pristupiti kroz $_REQUEST superglobal array, osim ako nemas register_globals ukljucen (sto je lako moguce). A ako ga nemas, onda tek te varijable nisu dostupne kao globalne varijable jednake imenu form polja, nego ti treba recimo $_POST['email'] ako je forma submitana post metodom...

Pomoglo bi i kako izgleda 0dio.php, tj. forma na toj stranici (ako se radi o formi), i ova temp.php - jer u ovom kodu sto si postao, nigdje se ne vidi sto ispisujes...

Takodjer, mozda ne bi bilo lose session startati jos u 0dio.php skripti, ako zelis pristupati session varijablama u temp.php i ranije/kasnije, etc... ono, pokreni ga odmah, pa ga imas kad ti zatreba...
Back to top
View user's profile Send private message Visit poster's website Twitter profile
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 23.06.2005 18:44    Post subject: Add user to your forum ignore list Reply with quote

Ok , a pazi sad ovo ... ovo sam napravio malo "bolju" session controlu :

Ovo je session :
Code:

<?php
// SESION TEST

 session_start();
 session_name("id");
 session_cache_expire(15);
 
if (isset($id)) {
 
  session_id($id);
 
    if (isset($triger) {
   
   // Ulovi iz forme
   $po1 = $_POST['polje1'];
   $po2 = $_POST['polje2'];
   
   // Registriraj nove $_SESSION
   $_SESSION[p1] = $po1;
   $_SESSION[p2] = $po2;
   }
   
 
}
else {
 $id = session_id(md5(uniqid(rand(), true)));
 header("Location: test1.php?".session_name()."=".session_id());
}

?>



Ovo je unos :

Code:

<?php include('session.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Session test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="center">
  <form name="form1" method="post" action="test2.php<?php echo'?'.session_name().'='.session_id(); ?>">
  <input name="triger1" type="hidden" value="triger1">
    <table width="500" border="0" cellspacing="5">
      <tr>
        <td width="100">polje 1 </td>
        <td width="390"><input type="text" name="polje1"></td>
      </tr>
      <tr>
        <td>polje 2 </td>
        <td><input type="text" name="polje2"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="Submit" value="&Scaron;alji &gt;&gt;"></td>
      </tr>
    </table>
  </form>
</div>
</body>
</html>



Ovo je druga stranica , na kojoj sve normalno ispisuje :

Code:

<?php
 include('session.php');
 
echo $_SESSION['po1'];
echo "<br><br>";
echo $_SESSION['po2'];
echo "<br><br>";

echo "<a href='test3.php?".session_name()."=".session_id()."'>Test3</a>";
 ?>



A ovo je treća stranica na kojoj neće ništa izbacit , i ja neznam zašto , jebalo ga to u guzicu ( već 5 dana pokušavam to složit )


Code:

<?php
include('session.php');

echo $_SESSION['po1'];
echo "<br><br>";
echo $_SESSION['po2'];
 ?>




Pomagajte .... di griješim , pa ja ne kužim , svu sam literaturu pročito i ništa...

cilj je šetat po stanicama kak očeš... sa stance 1 na stranicu 5 .. sa stranice 4 na stranicu 1 i uvijek nosit podatke sa sobom... i ako nemaš $id , onda odma te tera na 1stranicu i ideš odpočetka....

Eto Smile

Pliz help... Confused

_________________
have fun
Back to top
View user's profile Send private message
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 23.06.2005 19:04    Post subject: Add user to your forum ignore list Reply with quote

ovak od oka... u session stavljas

Code:

$_SESSION[p1] = $po1;
$_SESSION[p2] = $po2;


a citas

Code:
$_SESSION['po1'];
$_SESSION['po2'];


koje ti niti ne postoje po ovom kodu koji si napisao....

btw, probaj okinut na svakoj stranici
Code:
print_r($_SESSION);
zna bit korisno :)

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 23.06.2005 19:14    Post subject: Add user to your forum ignore list Reply with quote

Ma ovaj code gore sam sad nabrzaka uredio ... evo sad sve idem probat...
inače
www.inside.com.hr/radi-se/session je testni url Smile

_________________
have fun
Back to top
View user's profile Send private message
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 23.06.2005 19:29    Post subject: Add user to your forum ignore list Reply with quote

Evo , opet isti problem ...
na informacija unešena na test1.php je prikazana na test2.php , ali nije prikazana na test3.php

Mene zanima zašto i kao da to popravim.

@che.UP
koristio sam print_r ($_SESSION['p1']);

Sad

_________________
have fun
Back to top
View user's profile Send private message
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 23.06.2005 19:51    Post subject: Add user to your forum ignore list Reply with quote

ahaaaaaaaaa......znam... u session.php stavljas vrijednost $_POSTa u posebnu varijablu i onda to u session varijablu...... i to radis pri svakom pozivu stranice, a posto izmedju test2 i test3 nemas uopce POST ni ne mozes imat te vrijednosti u varijabli ovako kao si ti to napisao...

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 23.06.2005 19:56    Post subject: Add user to your forum ignore list Reply with quote

Jebemu Sad

Dali ima načina / prijedloga da se to riješi ?

Probao sam ovako :

Code:

    // Pogledaj jel triger tamo
   $triger = $_POST['triger1'];
   
    if ($triger == "1") {
   
   // Ulovi iz forme
   $po1 = $_POST['polje1'];
   $po2 = $_POST['polje2'];
   
   // Registriraj nove $_SESSION
   $_SESSION[p1] = $po1;
   $_SESSION[p2] = $po2;
   }
   
   else {
   $_SESSION[p1] = "pa zašto ne radiš ?";
   $_SESSION[p2] = "ja ću popizdit...";
   
   }


Sad na 3. stranici ispiše ovo "ja ću popizdit..." kako da ispiše ono što je unešeno na 1. stranici ?

_________________
have fun
Back to top
View user's profile Send private message
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 23.06.2005 20:10    Post subject: Add user to your forum ignore list Reply with quote

pa makni else i popuni session samo kod submita.... ovako ga stalno mijenjas, a potrebno ti je samo dobit vrijednost na pocetku...

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 23.06.2005 20:36    Post subject: Add user to your forum ignore list Reply with quote

Kada maknem

else {
}

Onda nema ništa na trečoj stranici... opće ne kužim.... još sam stavio if uvjet

if ($triger == "1" ) {
}

Shocked

_________________
have fun
Back to top
View user's profile Send private message
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 23.06.2005 22:18    Post subject: Add user to your forum ignore list Reply with quote

dziz... a kaj ti ispise print_r($_SESSION);? stavi to na svaku stranicu... imam osjecaj kao da nisi sav kod stavio...

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 23.06.2005 22:23    Post subject: Add user to your forum ignore list Reply with quote

Ovako izgleda druga i treća stranica , samo na drugoj sve ispiše , a na trećoj neće niš ! :

Code:

<?php
include('session.php');


print_r ($_SESSION['p1']);
echo "<br><br>";
print_r ($_SESSION['p2']);

echo "<a href='test4.php?".session_name()."=".session_id()."'>Test3</a>";
 ?>



Ovako izgleda session.php

Code:

<?php
// SESION TEST

 session_start();
 session_name("id");
 session_cache_expire(15);
 
if (isset($id)) {
 
  session_id($id);
 
    // Pogledaj jel triger tamo
   $triger = $_POST['triger1'];
   
    if ($triger == "1") {
   
   // Ulovi iz forme
   $po1 = $_POST['polje1'];
   $po2 = $_POST['polje2'];
   
   // Registriraj nove $_SESSION
   $_SESSION[p1] = $po1;
   $_SESSION[p2] = $po2;
   }
 
}
else {
 $id = session_id(md5(uniqid(rand(), true)));
 header("Location: test1.php?".session_name()."=".session_id());
}

?>

_________________
have fun
Back to top
View user's profile Send private message
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 23.06.2005 22:28    Post subject: Add user to your forum ignore list Reply with quote

http://www.php.net/session_id

Quote:
session_id() returns the session id for the current session.

If id is specified, it will replace the current session id. session_id() needs to be called before session_start() for that purpose. Depending on the session handler, not all characters are allowed within the session id. For example, the file session handler only allows characters in the range a-z, A-Z and 0-9!

Note: When using session cookies, specifying an id for session_id() will always send a new cookie when session_start() is called, regardless if the current session id is identical to the one being set.

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 23.06.2005 22:30    Post subject: Add user to your forum ignore list Reply with quote

Drugim riječima, moram prije pozvati session_id () pa tek onda ostatak priče ?

_________________
have fun
Back to top
View user's profile Send private message
1ONE



Joined: 13 Mar 2004
Posts: 136
Location: Zagreb

PostPosted: 24.06.2005 03:55    Post subject: Add user to your forum ignore list Reply with quote

Evo radi... makno sam mu da sam generira id i sad je sve ko curica.....
Fala che! Cool

_________________
have fun
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group