473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sessions and cookies

I have this little test application I made (see code below). I have looked
for a cookie that keeps track of the session but I cannot find one does PHP
use a cookie to keep track of the session?

Thanks for any help you can give!!!
First file
test.php
//*********** Start Here
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<FORM METHOD="POST" ACTION="test2.php">
Enter your Name: <input type="text" name="name">
<input type="SUBMIT" value="Submit">
</FORM>

</body>
</html>
Second file
test2.php
//*********** Start Here
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
// start the session
session_start();
//header("Cache-control: private"); //IE 6 Fix

// Get the user's input from the form
$name = $_POST['name'];

// Register session key with the value
$_SESSION['name'] = $name;

// Display the sssion information:
?>

Welcome to my website <strong><? echo $_SESSION['name']; ?></strong>!<br />
Let's see what happens on the <a href="test3.php">next page.</a><br /><br />
</body>
</html>
Third file
test3.php
//*********** Start Here
<?php
// start the session
session_start();
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Welcome to my website <strong><?php echo $_SESSION['name']; ?></strong>

</body>
</html>

Jul 17 '05 #1
7 1304

"Rick" <ri**@di-wave.com> wrote in message
news:l8*******************@twister.socal.rr.com...
I have this little test application I made (see code below). I have looked
for a cookie that keeps track of the session but I cannot find one does PHP
use a cookie to keep track of the session?

Thanks for any help you can give!!!

Am I on the right track do I need something liek this before each
session_start()?

$expireTime = 60*60*3; // 3 Hour
session_set_cookie_params($expireTime);
Jul 17 '05 #2
SSM
The code that you've put up seems to work very fine. And also, session
variables are kept in the server and cookies are not used for that
purposes. Could you please let me know, on which platform you're trying
this? And whats the problem that you're getting?

Jul 17 '05 #3
It is not realy a problem I just cannot figure out how php keeps track of
which session verable belongs to who with out a cookie?

Rick

"SSM" <ss****@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
The code that you've put up seems to work very fine. And also, session
variables are kept in the server and cookies are not used for that
purposes. Could you please let me know, on which platform you're trying
this? And whats the problem that you're getting?

Jul 17 '05 #4
Rick (ri**@di-wave.com) wrote:
: It is not realy a problem I just cannot figure out how php keeps track of
: which session verable belongs to who with out a cookie?

I have not had to worry about precisely how php sessions worked. Some
languages use cookies if available, or url rewriting if it isn't.

How did you check for cookies? Did you monitor the network traffic to see
the headers?

--

This space not for rent.
Jul 17 '05 #5

"Rick" <ri**@di-wave.com> wrote in message
news:l8*******************@twister.socal.rr.com...
I have this little test application I made (see code below). I have looked
for a cookie that keeps track of the session but I cannot find one does PHP
use a cookie to keep track of the session?
Thanks for any help you can give!!!


When you issue the first session_start(), php generates an internal session
number and by default tells the client to create a cookie named "PHPSESSID".

subsequent session_start() calls cause PHP to read the session ID from the
cookie, and load the $_SESSION[] auto-global array from a disk file on the
web server (aka session data store). (Don't know the name of these session
data files)

The $_SESSION[] array is written back to disk when the php script ends.

You can change the way the session passing and storage works, but the above
is default behavior, according to the O'Rielly "Learning PHP5" book.

-- Dan
Jul 17 '05 #6
SSM
In windows, you can see the session files created in the directory
specified in the php.ini for saving the session variables. The files
will have the same name as the session identifier.

Jul 17 '05 #7
Thanks everyone!!

"Rick" <ri**@di-wave.com> wrote in message
news:kj******************@twister.socal.rr.com...
It is not realy a problem I just cannot figure out how php keeps track of
which session verable belongs to who with out a cookie?

Rick

"SSM" <ss****@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
The code that you've put up seems to work very fine. And also, session
variables are kept in the server and cookies are not used for that
purposes. Could you please let me know, on which platform you're trying
this? And whats the problem that you're getting?


Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: windandwaves | last post by:
Hi Gurus I am basically sorry that I have to bother you about this. I am a PHP beginner and I have been studying sessions and cookies over the last few weeks. I have learned lots, but I am...
6
by: JJ | last post by:
Hi, I really need to use cookieless ASP sessions with ASP 3 (IIS5) Can I find out the session ID from the first page, then post it or send it with the url to the next page, then at the start...
2
by: | last post by:
Its strange...I have experimenting with browser hawk by using the cookie sniffer method. However, even If adjust the security slider level in internet options or goto advanced in the privacy tab I...
2
by: Steve Franks | last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting a value in the config.web file. However, what if I wanted to determine at run time whether or not I wanted to use...
2
by: Chris Mahoney | last post by:
Hi I'm using several Sessions in my app. When the user has cookies enabled in their browser, everything works fine. But with cookies disabled, only IE seems to remember the sessions. In Firefox...
7
by: Atte André Jensen | last post by:
Hi I'm developing a site where I'd like to store information during a users visit. So far I've been using sessions, but as far as I can tell it's not possible to control for how long a session...
6
by: Paul | last post by:
Here is a question that should get everyone going. I have an ecommerce site where I need to pass the order_id to every page. So which method is the best practice to pass this variable between...
13
Frinavale
by: Frinavale | last post by:
One of the most fundamental topics in web design is understanding how to pass information collected on one web page to another web page. There are many different ways you could do this: Cookies,...
5
by: jheines | last post by:
I am trying to explain how cookies and sessions work in a class I teach, but I have hit a wall when it comes to the interaction between cookies and the state of the privacy settings in Internet...
8
by: Chuck Anderson | last post by:
I've instituted a sessions based scheme on my web site to combat hot linking to my images. When someone requests a page at my site, I set a session variable. I then use htaccess to redirect *all*...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.