Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17722

PHP sessions

From madwomans Dad <dsvirtual58@gmail.com>
Newsgroups comp.lang.php
Subject PHP sessions
Date 2018-05-06 09:19 +0100
Organization A noiseless patient Spider
Message-ID <pcmdpu$2ek$1@dont-email.me> (permalink)

Show all headers | View raw


I'm new to this group and to PHP.
I'm very familiar with Java and I'm trying to compare PHP session 
handling with J2EE session handling and I've come up with a bit of a 
problem.

I have the following code in step1.php. code for sessionStatus shown after

step1.php, redirect commented out

<?php
require '../functions/utilities.php';

echo "step1 - check session - ";
sessionStatus();
echo "<br> starting session";
session_start();
echo "<br> session started";
sessionStatus();
//header("location: step2.php");
?>

I get the following output
step1 - check session -
there is no session
starting session
session started
there is an active session

if I then enable the redirect to step2.php

step2.php

<?php
require '../functions/utilities.php';

echo "step2 - check session - ";
sessionStatus();
?>

I would expect to see "there is an active session" but what I get is

step2 - check session -
there is no session

Huh! what am I missing
thanks

code for sessionStatus

function sessionStatus(){
    echo "<br>";
    switch (session_status()) {
	case PHP_SESSION_DISABLED:
         echo "session is disabled";
	break;
	case PHP_SESSION_NONE:
	echo "there is no session";
	break;
	case PHP_SESSION_ACTIVE:
	echo "there is an active session";
	break;
	default:
	echo "unknown status";
	}
}

Back to comp.lang.php | Previous | NextNext in thread | Find similar | Unroll thread


Thread

PHP sessions madwomans Dad <dsvirtual58@gmail.com> - 2018-05-06 09:19 +0100
  Re: PHP sessions "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-05-06 12:51 +0200
    Re: PHP sessions madwomans Dad <dsvirtual58@gmail.com> - 2018-05-06 12:59 +0100
      Re: PHP sessions "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-05-06 14:11 +0200
      Re: PHP sessions Gregor Kofler <usenet@gregorkofler.com> - 2018-05-06 14:13 +0200
        Re: PHP sessions madwomans Dad <dsvirtual58@gmail.com> - 2018-05-06 14:08 +0100
          Re: PHP sessions "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-05-06 15:22 +0200
            Re: PHP sessions madwomans Dad <dsvirtual58@gmail.com> - 2018-05-06 16:01 +0100
              Re: PHP sessions "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-05-06 17:27 +0200
                Re: PHP sessions madwomans Dad <dsvirtual58@gmail.com> - 2018-05-06 19:17 +0100
      Re: PHP sessions "J.O. Aho" <user@example.net> - 2018-05-06 18:57 +0200
  Re: PHP sessions Richard Damon <Richard@Damon-Family.org> - 2018-05-06 13:21 -0400

csiph-web