Latest

Archive

Community news

C++

Communities and Content

Databases

Editorials

Emacs

General

HTML

Java

Notices

PHP

XML

Apache

C++

Database

General

HTML

Java

Javascript

Linux

Object oriented programming

Open source

Perl

PHP

Python

Ruby

SOAP

XML

Suggest a link

Advertise on zez

Contribute

Contact us

About zez


PHP4 sessions


Categories PHP Code

Topic:

PHP4 sessions

Author:

Steve Yelvington

Time:

10.11.2000 10:32

Text:

>
> The two problems I am currently struggling with are, first: how do
> I pass SID to the initial page, the one that starts the session

You don't. That doesn't make sense. If the session has not yet been created, there is no session ID to pass, nor should one be necessary.

A session ID will be created, if one does not exist, when you call session_register() to implicitly begin a session.

Sessions are VERY simple, and most session problems are traceable to people trying to make them more complicated than they need to be.

session_destroy(); // delete any old session info

$foo = "hello";
$bar = "world";
session_register("foo", "bar");

Now, on another page you can
session_start();
echo "$foo, $bar!!";

If you must pass around session IDs in URLs, use the constant SID to do so. It contains both the session name and the value in the proper format. If the user has cookies enabled, SID will be empty and that whole bit of ugliness will disappear.



Message threads

Topic: Author:
Time:
PHP4 sessions Gera Makarov 10.11.2000 10:32  
  PHP4 sessions Steve Yelvington 10.11.2000 10:32  
   RE: PHP4 sessions test test 28.11.2000 13:22  
   test coolname new 10.11.2000 10:32  


Forgot your password?

Register a new user

Results

Polls