Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

$_SESSION problem

General discussions related to php

Moderators: macek, egami, gesf

$_SESSION problem

Postby webtekie » Thu Apr 17, 2003 11:21 am

Hello,

I am noticing something strange happening when I use $_SESSION object. On one page I set session, on next I display it. The problem is that too often on a second page value of my $_SESSION variable is not displayed.
Any suggestions?

sess.php
========
<?php
session_start();
$_SESSION['test'] = "HELLO";
header("Location: sess2.php");
?>

sess2.php
=========
<?php
session_start();
echo "test: " . $_SESSION['test'];
?>

/alex
webtekie
New php-forum User
New php-forum User
 
Posts: 9
Joined: Thu Apr 10, 2003 10:33 am
Location: brooklyn, ny

Postby Redcircle » Thu Apr 17, 2003 11:24 am

I have noticed that problem before too. The only explaination that I can come up with is that the cookie has not yet been created on the clients computer with the session information. I would try passing the session id on the URL
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby webtekie » Thu Apr 17, 2003 11:36 am

thanks, I am new at this, so can you suggest a link where I can find more info?
webtekie
New php-forum User
New php-forum User
 
Posts: 9
Joined: Thu Apr 10, 2003 10:33 am
Location: brooklyn, ny

hi redcircle

Postby ruturajv » Fri Apr 18, 2003 7:36 pm

does
Code: Select all
$_SESSION['varname'] = value

is it same as
Code: Select all
session_register('varname') = value


Please ans
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby webtekie » Mon Apr 21, 2003 7:13 am

That's exectly what I am using, but still causes problem. Some people suggested upgrading to a newer version of PHP, but others say that problem still exists. This problem is very strange since values of session object are lost at random. It's not easy for me to upgrade to a newer version of PHP since I am outsourcing my site at a web host, I guess I 'll try upgrading on my pc at home.

/webtekie
webtekie
New php-forum User
New php-forum User
 
Posts: 9
Joined: Thu Apr 10, 2003 10:33 am
Location: brooklyn, ny

Postby Godiwa » Wed May 07, 2003 1:12 pm

there is a problem with it but I got one of the newer versions of PHP and found a way around it, setting the var is the same way as you already did it, BUT viewing it is a little different

<?php
session_start();
$test = $_SESSION['test'];
echo "test: " . $test;
?>

that should solve the problem, tedious but works for me, same problem I had if I had some session variables that I wanted to put in with form info, make a normal var first, seems to do the trick.

use the new session info and forget $session_register, don't use it anymore, read about sessions in the new help file that comes out with PHP lot of great info in it

Godiwa
Godiwa
New php-forum User
New php-forum User
 
Posts: 40
Joined: Wed Mar 05, 2003 5:55 am

Postby php-punk » Tue Jun 10, 2003 3:13 am

well for me it has worked easily as:

php1:

<?

$test="rah";
session_start();
session_register($test);
?>

PHP:
<?
session_start();
echo $test;
?>

this has always worked fine for me!!
php-punk
New php-forum User
New php-forum User
 
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk


Return to PHP General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.