Jump to content

HELP on sessions


huiling25

Recommended Posts

I am making a e-shopping kind of website. Using dreamweaver mx2004, IIS server, mysql5.0, php5. i hand-code my log in user. however, i realised tt when the page redirect ito another page, the session is empty. but the page tt is checking my log in, the session has the username. but after redirecting (using header), the session becomes empty. This is my code:

 

$_SESSION['user']=$username;

header("Location: ./test.php");

 

Can anyone helped me?

Link to comment
https://forums.phpfreaks.com/topic/60225-help-on-sessions/
Share on other sites

Your code:

$_SESSION['user']=$username;

header("Location: ./test.php");

 

After u have ensured that u have used session_start() in both the pages.

You need to check if the variable $username is holding any value or not.If this variable

is set to somevalue then the session variable holds it.What if this variable is set to null ?This situation might have occured to ur code.Plz check once!!!

 

 

Link to comment
https://forums.phpfreaks.com/topic/60225-help-on-sessions/#findComment-299998
Share on other sites

I had tried doing this:

 

checklogin.php

<?php

session_start();

$_SESSION['user']='John';

 

header("Location: ./test.php");

?>

 

test.php

<?php session_start();?>

<html>

<head>

</head>

 

<body>

Hello, <?php

echo $_SESSION['user'];?>

 

</body>

</html>

 

But on test.php, the result i see is only

 

Hello,

Link to comment
https://forums.phpfreaks.com/topic/60225-help-on-sessions/#findComment-300801
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.