time will never be equal to the session id. Your code said you were making the “session ID” = time.
print "Your SessionID: ".time();
Right there.
If you’re trying to find out what the session id is, use [FPHP]session_id[/FPHP] (isnt it amazing how so many of the commands are actually named exactly what you’re looking for, and a simple manual search would find them?)
k i have got session id with the above code.
now i need to re direct to another page called “products.php” which contains 3 products
how to add that extra thing…
i have done.
but it is showing the error Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\sess2.php:8) in C:\xampp\htdocs\sess2.php on line 10
below is the location added code
<?php
session_start();
mysql_connect("localhost","root","") or die("mysql_error()");
mysql_select_db("shopping") or die("mysql_error()");
if(isset($_SESSION['username']))
{
$time = time();
print "Your SessionID: ".$time;
$_SESSION['username'] = $time;
header("Location:products.php");
}
else
{
print "Session does not exist";
}
?>
You cant send a header() after printing something to the screen. (It wont be visible after you change the location, anyway, so you might as well not print it)