 |
| Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 3rd, 2004, 05:49 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Session Management wanted some help
any one would like to tech me session mangaement in php or any on
who told me the resources or artical or any session mangement stuff
i have book named begining php 4 but it has not much discussion about
that my request specialy for Nikolai
|
|

March 3rd, 2004, 04:46 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Everything there is to know
----------
---Snib---
----------
|
|

March 3rd, 2004, 08:36 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
To put it simply, sessions give you a way to persist the value of variables between page requests.
To use sessions, simply start your scripts with session_start(). Any values you want to store in sessions is simply inserted into the $_SESSIONS array.
Simple example:
<?php
session_start();
if (!isset($_SESSION['count']))
{
$_SESSION['count'] = 0;
}
++$_SESSION['count'];
echo "You've seen this page {$_SESSION['count']} times.\n";
?>
Take care,
Nik
http://www.bigaction.org/
|
|

March 4th, 2004, 12:39 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
dear nikolai
when i use ur code my browser say the warnings as under
and page conunt doesnt incremented
---------------------------------------
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\inetpub\wwwroot\mysql\sessiontesting.php:8) in d:\inetpub\wwwroot\mysql\sessiontesting.php on line 9
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\inetpub\wwwroot\mysql\sessiontesting.php:8) in d:\inetpub\wwwroot\mysql\sessiontesting.php on line 9
You've seen this page 1 times.
----------------------------------
what is the problem pls tell me
thanks
|
|

March 4th, 2004, 01:15 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
This is probably because you have output before session_start()
This doesn't work:
<html>
<?php
session_start();
?>
</html>
This also doesn't work:
<?php
echo "<html></html>";
session_start();
?>
session_start() comes before any other output, as it has to do with headers.
HTH,
----------
---Snib---
----------
|
|

March 4th, 2004, 05:10 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Also, make sure there's no extra whitespace before your <?php tags. The most subtle reason for this error is that there's a newline or space before the first <?php tag.
Take care,
Nik
http://www.bigaction.org/
|
|

March 4th, 2004, 05:37 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I should add the reason for the error: Sessions are managed by PHP using cookies by default. The session data is all stored on the web server machine, in session files by default. However, the session ID is stored in a cookie on the client machine. The session ID uniquely identifies the session data file on the server.
As such, all cookie fetch and store requests are sent as part of the HTTP header information before any output is sent.
Take care,
Nik
http://www.bigaction.org/
|
|

March 5th, 2004, 01:13 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The problems have solved thanks all specially nikoloi and snib
pls can u give me ur msn id if u like
|
|

March 12th, 2004, 04:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm glad you got it working. I don't use IM apps, and prefer all questions to be posted to the forums rather than to IM or personal email anyway...
Take care,
Nik
http://www.bigaction.org/
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Session management |
Gemz |
.NET Framework 2.0 |
1 |
October 26th, 2008 04:56 AM |
| Session Management |
yohandh |
General .NET |
2 |
December 12th, 2005 10:45 PM |
| session management |
G_Zola |
General .NET |
2 |
June 12th, 2005 07:58 PM |
| Session management |
texasraven |
ASP.NET 1.x and 2.0 Application Design |
6 |
April 21st, 2004 04:42 PM |
| Session Management |
ManoYaka |
ASP.NET 1.0 and 1.1 Professional |
1 |
January 23rd, 2004 07:02 AM |
|
 |