| | |
session in php
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 45
Reputation:
Solved Threads: 2
i'm a newbie in php and maybe my question is so silly.
i tried to create a session in a file named login.php
but, $_SESSION['level'] is not recognized in other files like manager.php, gudang.php, and kasir.php
is there something wrong with my code?
thanks for your helps.
i tried to create a session in a file named login.php
PHP Syntax (Toggle Plain Text)
<?php include "koneksi.inc.php"; $name=$_POST['name']; $password=$_POST['password']; $hasil=mysql_query("SELECT * FROM TabelPegawai WHERE nama='$name' AND password='$password'"); $row=mysql_fetch_array($hasil); if ($row[nama]==$name AND $row[password]==$password) { session_start(); $_SESSION['namauser']=$row[nama]; $_SESSION['passuser']=$row[password]; $_SESSION['level']=$row[jabatan]; if($_SESSION['level']=="Manager") {header("location: manager.php");} else if($_SESSION['level']=="Kasir") {header("location:kasir.php");} else if($_SESSION['level']=="Gudang") {header("location:gudang.php");} else {header("location:http://www.google.com");} } else {header("location:http://www.yahoo.com");} ?>
but, $_SESSION['level'] is not recognized in other files like manager.php, gudang.php, and kasir.php
is there something wrong with my code?
thanks for your helps.
Last edited by AirGear; 26 Days Ago at 3:32 pm.
•
•
Join Date: Jul 2009
Posts: 45
Reputation:
Solved Threads: 2
0
#4 26 Days Ago
oh, it works if i start the session in every page that needs session variables. i also must start the session in a php file that destroy the session right? like this :
am i right?
PHP Syntax (Toggle Plain Text)
<?php session_start(); session_destroy(); ?>
am i right?
•
•
Join Date: Nov 2008
Posts: 73
Reputation:
Solved Threads: 1
0
#5 26 Days Ago
•
•
•
•
oh, it works if i start the session in every page that needs session variables. i also must start the session in a php file that destroy the session right? like this :
PHP Syntax (Toggle Plain Text)
<?php session_start(); session_destroy(); ?>
am i right?
PHP Syntax (Toggle Plain Text)
if (!isset($_SESSION)) { session_start(); }
Dave
-1
#6 26 Days Ago
You don't need to check. session_start() will not start a new session overwriting the old one. It just propagates.
session_destroy wouldn't be used very often, unless in a logout page or similar. You wouldn't have a session_start in this file as well (I don't think).
session_destroy wouldn't be used very often, unless in a logout page or similar. You wouldn't have a session_start in this file as well (I don't think).
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
•
•
Join Date: Nov 2008
Posts: 73
Reputation:
Solved Threads: 1
0
#7 26 Days Ago
•
•
•
•
You don't need to check. session_start() will not start a new session overwriting the old one. It just propagates.
session_destroy wouldn't be used very often, unless in a logout page or similar. You wouldn't have a session_start in this file as well (I don't think).
D
![]() |
Similar Threads
- How to start new session in php (PHP)
- Session in PHP (PHP)
- please help me in session in php (PHP)
- Need help with session in php..... (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP echo email address as mailto
- Next Thread: redirecting in php
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





