RE: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread Don
Dazed and confused.  I've tried the suggestions thus far (I believe) and no
luck.  Below is the current code.  For somw reason, when I disable cookies
in my browser:

1. The session ID is NOT being passed in the URL
2. The session ID changes everytime I click on the link; probably because it
creates a new session evertime.

Suggestions?

= Start of Code =
?php
session_start(); 
header(Cache-control: private); //IE 6 Fix 
if(!$_SESSION['count']){ 
$_SESSION['count'] = 1;
$sid = session_id();
echo 'pSession is: ' . $sid . '/p';
} else { 
$_SESSION['count']++; 
} 
echo 'pYou have visited ? echo $_SESSION[\'count\']; ? pages so
far!/p';
echo 'pa href=test.php?sid=' . $sid . 'Increment Your
Counter!/a/p';
?
== End of Code ==

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread Don
OK!  I got it to work. Although session_id() would not work, using the SID
constant did.  Below is the code I used:

= Start of Code =
?php
session_start(); 
header(Cache-control: private); //IE 6 Fix 
if(!$_SESSION['count']){ 
$_SESSION['count'] = 1;
echo 'pFirst time through/p';
} else { 
$_SESSION['count']++; 
} 
?

pYou have visited ? echo $_SESSION['count']; ? pages so far!/p
A HREF=test.php??php echo SID?Increment Your Counter!/A== End of
Code ==

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread Matt M.
 = Start of Code =
 ?php
 session_start();
 header(Cache-control: private); //IE 6 Fix
 if(!$_SESSION['count']){
 $_SESSION['count'] = 1;
 $sid = session_id();
 echo 'pSession is: ' . $sid . '/p';
 } else {
 $_SESSION['count']++;
 }
 echo 'pYou have visited ? echo $_SESSION[\'count\']; ? pages so
 far!/p';
 echo 'pa href=test.php?sid=' . $sid . 'Increment Your
 Counter!/a/p';
 ?

are you sure $sid is getting set?

this if(!$_SESSION['count']) might skip it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread John Holmes
From: Don [EMAIL PROTECTED]
OK!  I got it to work. Although session_id() would not work, using the SID
constant did.  Below is the code I used:
Compare the URL created with this:
A HREF=test.php??php echo SID?Increment Your Counter!/A
to the URL created with this:
echo 'pa href=test.php?sid=' . $sid . 'Increment Your
Counter!/a/p';
and you'll see the reason why the second didn't work.
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re:Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread fongming
Hi:

You also  can use follows:

a href=script.php?PHPSESSID=session_id();/a



--
¡»From: ¦¹«H¬O¥Ñ®ç¤p¹q¤l¶l¥ó1.5ª©©Òµo¥X...
http://www.tyes.tyc.edu.tw
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread fongming
Hi:

May be you can use follows:
a href=some_script.php?PHPSESSId=?php session_id();? some thing/a

--
¡»From: ¦¹«H¬O¥Ñ®ç¤p¹q¤l¶l¥ó1.5ª©©Òµo¥X...
http://www.tyes.tyc.edu.tw
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re:Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread John Holmes
From: fongming [EMAIL PROTECTED]
You also  can use follows:
a href=script.php?PHPSESSID=session_id();/a
You can, if you want to make the (incorrect) assumption that everyone will 
have PHPSESSID as the name of their sessions...

That's what session_name() is for and the SID constant...
---John Holmes... 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re:Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-20 Thread Chris Shiflett
--- John Holmes [EMAIL PROTECTED] wrote:
 From: fongming [EMAIL PROTECTED]
  You also  can use follows:
 
  a href=script.php?PHPSESSID=session_id();/a
 
 You can, if you want to make the (incorrect) assumption that everyone
 will have PHPSESSID as the name of their sessions...
 
 That's what session_name() is for and the SID constant...

Yep, and...

That syntax is wrong anyway - session_id() only returns the session
identifier when used in PHP, not within HTML. :-)

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-19 Thread Don
Hi,
 
I have a PHP file containing the code below.  It works great when all
default setting exist in IE; each time I click on refresh, the session
variable is incremented and displays on the screen.  If I change my browsers
setting to block all cookies, my session variable appears not to increment
and refreshing the screen displays the same text all the time.
 
Q1. Is this because sessions use session cookies and IE blocks these at high
security?
 
Q2. I was told that if cookies are turned off, there is a way to use the
session ID variable to accomplish what I want instead of cookies.  How can I
do this OR please point me to an easy tutorial.
 
Thanks,
Don
 
== Start of code ==
?PHP
session_start(); 
header(Cache-control: private); //IE 6 Fix 
if(!$_SESSION['count']){ 
$_SESSION['count'] = 1; 
} else { 
$_SESSION['count']++; 
} 
?
You have visited ? echo $_SESSION['count']; ? pages so far!
=== End of code ===
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-19 Thread Matt M.
On Thu, 19 Aug 2004 16:50:28 -0400, Don [EMAIL PROTECTED] wrote:
 Hi,
 
 I have a PHP file containing the code below.  It works great when all
 default setting exist in IE; each time I click on refresh, the session
 variable is incremented and displays on the screen.  If I change my browsers
 setting to block all cookies, my session variable appears not to increment
 and refreshing the screen displays the same text all the time.
 
 Q1. Is this because sessions use session cookies and IE blocks these at high
 security?
 
 Q2. I was told that if cookies are turned off, there is a way to use the
 session ID variable to accomplish what I want instead of cookies.  How can I
 do this OR please point me to an easy tutorial.

rtm
http://us4.php.net/session

session.use_trans_sid

SID

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-19 Thread Jake Stonebender
On Thu, 19 Aug 2004 16:50:28 -0400, Don [EMAIL PROTECTED] wrote:
 Q1. Is this because sessions use session cookies and IE blocks these at high
 security?
 
 Q2. I was told that if cookies are turned off, there is a way to use the
 session ID variable to accomplish what I want instead of cookies.  How can I
 do this OR please point me to an easy tutorial.

Basically, in order for your session to work, you have to let the page
that you're viewing know what the session id is.  Let's look at your
code.

 == Start of code ==
 ?PHP
 session_start();
 header(Cache-control: private); //IE 6 Fix
 if(!$_SESSION['count']){
 $_SESSION['count'] = 1;
 } else {
 $_SESSION['count']++;
 }
 ?
 You have visited ? echo $_SESSION['count']; ? pages so far!
 === End of code ===

Looking at this code, there's no link to another page, so there's no
way of letting the web server (and PHP in this case) know what the
session id is.  If your php.ini hasn't been changed, you could see the
session in action by adding a link that points to the same page.  Say
for example, the name of this file is 'session.php'.  Add the
following line to your page:

a href=session.phpSee the session in action!/a

PHP will rewrite this to:

a href=session.php?SID=12345678123456781234567812345678See the
session in action!/a

Clicking on the link will then show $_SESSION['count'] incrementing. 
You should have seen something similar even if you have cookies the
first time you start your browser (assuming your only using session
cookies) since PHP hasn't received any session information from the
browser.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How do I use sessions if cookies are turned off in the browser?

2004-08-19 Thread John Holmes
Don wrote:
If I change my browsers
setting to block all cookies, my session variable appears not to increment
and refreshing the screen displays the same text all the time.
You need to pass the session id in the URL if cookies are off. There is 
a constant, SID, that you may be able to use, or otherwise create it 
with session_name() and session_id().

$link = 'http://www.yourdomain.com/page.php?'.SID;
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php