how to pass session_id() throught out the php pages?

Posted by Piyush on Stack Overflow See other posts from Stack Overflow or by Piyush
Published on 2010-05-15T11:13:32Z Indexed on 2010/05/15 11:24 UTC
Read the original article Hit count: 200

Filed under:
|
|

when user clicks on login button(index.php) I am calling chechlogin.php where I am checking loginId an password as-

if($count==1)
{
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
$_SESSION['UserId'] = $myusername;
$_session['SessionId'] = session_id();
header("location:LoggedUser.php");
}

in LiggedUser.php

<?php session_start();  //starting session

if (!isset($_SESSION['SessionId']) || $_SESSION['SessionId'] == '') { header("location:index.php"); } ?>

Problem: It is always going back to index.php page although I am entering right userid and password.I think session_id() is not working properly or ??

© Stack Overflow or respective owner

Related posts about php

Related posts about session