...

View Full Version : redirect with session problem



GNabeeh
06-29-2005, 10:29 AM
I made login page.
When the user enter correct data I but his id in session variable and redirect the page.
If the data is in correct it redirect to another page.
This code worked on my local machine but when uploaded to the server it didn't work with this redirect the other pages don't see the session variable
but when I remove the redirect code and puts links to user for navigation it works and the pages see the session variable.

The server have many site and this happen in this site only.
thanks in advance

ClubCosmic
06-29-2005, 01:46 PM
please post some code to give a clearer view

GNabeeh
06-30-2005, 12:42 PM
The following is the code which check for the user and if correct redirect the page to mydata.php page

header("location: mydata/mydata.php");

This code didn't work.And when I put links instead of redirct it worked

<?php
session_start() ;
mysql_select_db($database_conn, $conn);
$query_rs = "SELECT * FROM user where user_mobileNo='$mobile' and user_password = '$password' ";
$rs = mysql_query($query_rs, $conn) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
if ($totalRows_rs > 0) {
session_start() ;
session_register ("userid") ;
$userid=$row_rs['user_id'];
header("location: mydata/mydata.php");
}
if ($totalRows_rs == 0) { // Show if recordset empty
header("location: login.php");
}

delinear
06-30-2005, 02:11 PM
Don't use the session_register ("userid"); format, this is deprecated and it won't work if register_globals is disabled, instead use the $_SESSION['userid'] format to work with session variables.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum