Session not display

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
inspire
Forum Newbie
Posts: 1
Joined: Tue Sep 18, 2007 8:34 pm

Session not display

Post by inspire »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hello Friend,

i have a problem to pass the session value to other page.
here the example


[u][b]page 1[/b][/u]

Code: Select all

<?php
//session_register('xyz');
$HTTP_SESSION_VARS['name']="xyz";
?>

<html>
<head>
<form action="page2.php" method="post">
<body>
   <input type="Submit" name="login" value="login">
   <input type="input" name="login" >
  </head>
</form>
</body></html>

Page2.php

Code: Select all

<?php
session_start();
echo $HTTP_SESSION_VARS['name'];

$name=$HTTP_POST_VARS['login'];

echo $name;
?>

I am using Php 4.0.5. Why this problem accur?? Anybody know how to solve ethe problem?.
:(


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

Place

Code: Select all

session_start();
at the top of page 1.

Also, you could simply declare your session variables like this

Code: Select all

$_SESSION['name']="xyz";
nhammond
Forum Newbie
Posts: 14
Joined: Mon Dec 18, 2006 11:35 am

Post by nhammond »

yeah that http_vars stuff is the old school php way, just need session_start(); and then $_SESSION[''];
Post Reply