How to delete an entry from "My quotes"?
sessions
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > Perl web-programming > sessions 25 August 2008 20:20:55

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

sessions

Octavian Rasnita 25 August 2008 20:20:55
 Hi all,

I have seen that in PHP there are some functions that allow adding some
field=value pairs to the QUERY_STRING, automaticly for all the links from a
page and also in forms.

This might be helpful when I want to add the session id to the query_string
like &cgisessid=[session id].

Do you know if there are some modules that can make this with perl?

I think it wouldn't be too complicate to do it manually, but it would be
more simple to make it using a module, something like:

use ModuleName;
my $module = ModuleName->new();
$module->replace_al­l($text_of_page, 'cgisessid', '[session id]');

And these lines should replace the text of the page contained in
$text_of_page, in such a way that:

<a href="test.pl">Test­</a>
will become:
<a href="test.pl?cgise­ssid=[session id]">Test</a>

and

<a href="test.pl?var1=­val1">Test</a>
will become:
<a href="test.pl?var1=­val1&cgisessid=[session id]">Tes­t</a>

and

<a href="test.pl?cgise­ssid=[another session id]">Test</a>
will become:
<a href="test.pl?cgise­ssid=[session id]">Test</a>

and

<form action="/cgi-bin/te­st.pl" method="POST">
<input type="text" name="q" />
<input type="submit" value="Ok" />
</form>

will become:

<form action="/cgi-bin/te­st.pl" method="POST">
<input type="hidden" name="cgisessid" value="[session id]" />
<input type="text" name="q" />
<input type="submit" value="Ok" />
</form>


Is there any perl module that does this, or something similar? It would be
great to be and I am almost sure it should be.

I know that this method could have some issues that should be solved in
other way, for example in the case of the records taken from a database and
sent directly to the browser, or when $| = 1... but for many other cases of
scripts that send the text buffered, it should work fine.

Thank you for any help.

PS. It would be wonderful if the module CGI::Session would have the option
for doing this.

Teddy


--
To unsubscribe, e-mail: beginners-unsubscri­be@perl.org
For additional commands, e-mail: beginners-help@perl­.org
<http://learn.perl.­org/> <http://learn.perl.­org/first-response>



Add comment
Martin A. Marques 24 June 2000 16:50:35 permanent link ]
 I want to know how transparent sessions are?

I got this script:

<?
if(!isset($PHP_AUTH­_USER)) {
Header("WWW-Authent­icate: Carga basic=\"Carga de datos\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Text to send if user hits Cancel button\n";
exit;
} else {
echo "Hola $PHP_AUTH_USER.<P>"­;
echo "Tu contrase~na es $PHP_AUTH_PW .<P>";
}
?>

and I wanna know if the session would start automagaclly, if it would save
the users name and the password through all the session, and when would the
session be closed?

I would like it to clse after 1h of inactivity or when the person on the
other side closes the browser.

And to finish it, I would like to know where the user name and password are
kept.

thanks!!!!

--
"And I'm happy, because you make me feel good, about me." - Melvin Udall
-------------------­--------------------­--------------------­------
Martнn Marquйsemail: martin@math.unl.edu­.ar
Santa Fe - Argentinahttp://mat­h.unl.edu.ar/~martin­/
Administrador de sistemas en math.unl.edu.ar
-------------------­--------------------­--------------------­------
Add comment
Gabor Gludovatz 26 June 2000 01:23:31 permanent link ]
 Hi,

I have problems with php's session handling. The php parser inserts the
session_name=sessio­n_id string twice in the place of <?=SID?> everywhere,
and this way all my scripts became unusable. these scripts worked some
time but doesn't seem to do so now. I upgraded php some time ago, but I
realized it just now that my old working scripts don't work on my
homepage.

for example:
this is in the .php file: <a href="something.php­?<?=SID?>">
and this is what the browser gets:
<a href="something.php­??Session_Name=Sessi­on_IdSession_Name=Se­ssion_Id">

thanx in advance,
Gabor



Add comment
TomHenry 26 June 2000 05:54:45 permanent link ]
 
Scientific Wild A** Guess -- sounds like you _may_ be doing
BOTH of the following
(1) specifying urls as file.html?<?=SID?>
and
(2) compiled PHP4 with --enable-trans-id
which may be adding the SID again a second time

HTH
Tom Henry




At 12:23 AM 6/26/00 +0200, Gabor Gludovatz wrote:>Hi,>
I have problems with php's session handling. The php parser inserts the>session_name=se­ssion_id string twice in the place of <?=SID?> everywhere,>and this way all my scripts became unusable. these scripts worked some>time but doesn't seem to do so now. I upgraded php some time ago, but I>realized it just now that my old working scripts don't work on my>homepage.>
for example:>this is in the .php file: <a href="something.php­?<?=SID?>">>and this is what the browser gets:><a href="something.php­??Session_Name=Sessi­on_IdSession_Name=Se­ssion_Id">>
thanx in advance,> Gabor>
-->PHP General Mailing List (http://www.php.net­/)>To unsubscribe, e-mail: php-general-unsubsc­ribe@lists.php.net>F­or additional commands, e-mail: php-general-help@li­sts.php.net>To contact the list administrators, e-mail: php-list-admin@list­s.php.net

-------------------­--------------------­--------------------­---------
Strategic Business Systems (978) 745-2332
http://BusinessWebs­.com/
-------------------­--------------------­--------------------­---------


Add comment
Gabor Gludovatz 26 June 2000 11:55:02 permanent link ]
 On Sun, 25 Jun 2000, TomHenry wrote:
Scientific Wild A** Guess -- sounds like you _may_ be doing> BOTH of the following> (1) specifying urls as file.html?<?=SID?>>­ and> (2) compiled PHP4 with --enable-trans-id> which may be adding the SID again a second time

ok, it works, thank you... in the previous versions of php in debian it
was compiled without the --enable-trans-id switch.

but I still have a problem:
in the following situation only the second "<? echo $row... ?>" gets
printed

<a href="x.php?id=<? $row["id"]; ?>"><? echo $row["id"]; ?>

It should be working, shouldn't it?
but only <a href="x.php?id=&ses­s_name=sess_id">XY shows up in the browser.


thx, Gabor

--
Gabor Gludovatz <ggabor@sopron.hu> http://www.sopron.h­u/~ggabor/
"Microsoft shouldn't be broken up. It should be shut down."

Add comment
Thomas Deliduka 26 June 2000 17:58:24 permanent link ]
 I found it interesting that on 6/26/00 4:55 AM Gabor Gludovatz said:
but I still have a problem:> in the following situation only the second "<? echo $row... ?>" gets> printed>
<a href="x.php?id=<? $row["id"]; ?>"><? echo $row["id"]; ?>>
It should be working, shouldn't it?> but only <a href="x.php?id=&ses­s_name=sess_id">XY shows up in the browser.

This is the same problem I came up against and posted to this list with no
reply.
--

Thomas Deliduka
IT Manager
-------------------­------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.c­om/


Add comment
Jason Stechschulte 26 June 2000 18:01:23 permanent link ]
 There is no echo in front of the first $row["id"].

Jason Stechschulte
jpstech@nc.edu

-----Original Message-----
From: Thomas Deliduka [mailto:thomas@neweve.com]
Sent: Monday, June 26, 2000 10:58 AM
To: PHP List
Subject: Re: [PHP-GENERAL] sessions


I found it interesting that on 6/26/00 4:55 AM Gabor Gludovatz said:
but I still have a problem:> in the following situation only the second "<? echo $row... ?>" gets> printed>
<a href="x.php?id=<? $row["id"]; ?>"><? echo $row["id"]; ?>>
It should be working, shouldn't it?> but only <a href="x.php?id=&ses­s_name=sess_id">XY shows up in the browser.

This is the same problem I came up against and posted to this list with no
reply.
--

Thomas Deliduka
IT Manager
-------------------­------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.c­om/



--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, e-mail: php-general-unsubsc­ribe@lists.php.net
For additional commands, e-mail: php-general-help@li­sts.php.net
To contact the list administrators, e-mail: php-list-admin@list­s.php.net

Add comment
Thomas Deliduka 26 June 2000 18:08:56 permanent link ]
 I found it interesting that on 6/26/00 11:01 AM Jason Stechschulte said:
There is no echo in front of the first $row["id"].

In my example there was an echo, here's a re-send of the message I sent last
week:

----------
I have a problem and some questions, if this isn't the list to post to,
please let me know which one is.

First the question:
the session_start() function, must this be done at the top of every page
on the site; something that should be put into a header.inc file?


The problem:
I am going to be working on a process which is going to require session
variables. But here's what I have been reading. If it's in a cookie that
may not work if someone has disabled cookies so I'm thinking of using the
<?=SID?> technique.

But then I read that if I I compile with '--enable-trans-sid­' then I won't
have to do that. Oh, and to make my life easier, I decided to put into the
configuration file: session.auto_start = 1 (big mistake)

Many of my sites then stopped working. This is what I see happening:

Let's say I have code which will dynamically send someone to another
directory, I put the link:

http://www.domain.c­om/<? echo $directory; ?>

it works perfectly, it outputs: http://www.domain.c­om/mydirectory/

Well, with --enable-trans-sid on and this auto_start happening I get this as
an output:

http://www.domain.c­om/&PHPSESSID=763038­de1adfc7bbb955611686­a23e65004-20

It seems that whatever I echo there it is replaced by the session ID. I have
a link which links to a Real Audio File:

http://www.domain.c­om/freel.phtml?raid=­<? echo $rafile; ?>
which outputs
http://www.domain.c­om/freel.phtml?raid=­rafile.ram
but with this session thing on it gives me:
http://www.domain.c­om/freel.phtml?raid=­&SESSIONS=763038de1a­dfc7bbb955611686a
23e65004-20

I just don't get it! Anyone have any answers?
-------------

--

Thomas Deliduka
IT Manager
-------------------­------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.c­om/


Add comment
Jason Stechschulte 26 June 2000 18:59:46 permanent link ]
 The message I replied to contained this statement:
<a href="x.php?id=<? $row["id"]; ?>"><? echo $row["id"]; ?>

And there really is no echo in front of the first $row["id"]. The problem
that you are describing is different. I have no idea why you are having
that problem. You might be better off posting to the developer list.

Jason

-----Original Message-----
From: Thomas Deliduka [mailto:thomas@neweve.com]
Sent: Monday, June 26, 2000 11:09 AM
To: PHP List
Subject: Re: [PHP-GENERAL] sessions


I found it interesting that on 6/26/00 11:01 AM Jason Stechschulte said:
There is no echo in front of the first $row["id"].

In my example there was an echo, here's a re-send of the message I sent last
week:

----------
I have a problem and some questions, if this isn't the list to post to,
please let me know which one is.

First the question:
the session_start() function, must this be done at the top of every page
on the site; something that should be put into a header.inc file?


The problem:
I am going to be working on a process which is going to require session
variables. But here's what I have been reading. If it's in a cookie that
may not work if someone has disabled cookies so I'm thinking of using the
<?=SID?> technique.

But then I read that if I I compile with '--enable-trans-sid­' then I won't
have to do that. Oh, and to make my life easier, I decided to put into the
configuration file: session.auto_start = 1 (big mistake)

Many of my sites then stopped working. This is what I see happening:

Let's say I have code which will dynamically send someone to another
directory, I put the link:

http://www.domain.c­om/<? echo $directory; ?>

it works perfectly, it outputs: http://www.domain.c­om/mydirectory/

Well, with --enable-trans-sid on and this auto_start happening I get this as
an output:

http://www.domain.c­om/&PHPSESSID=763038­de1adfc7bbb955611686­a23e65004-20

It seems that whatever I echo there it is replaced by the session ID. I have
a link which links to a Real Audio File:

http://www.domain.c­om/freel.phtml?raid=­<? echo $rafile; ?>
which outputs
http://www.domain.c­om/freel.phtml?raid=­rafile.ram
but with this session thing on it gives me:
http://www.domain.c­om/freel.phtml?raid=­&SESSIONS=763038de1a­dfc7bbb955611686a
23e65004-20

I just don't get it! Anyone have any answers?
-------------

--

Thomas Deliduka
IT Manager
-------------------­------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.c­om/



--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, e-mail: php-general-unsubsc­ribe@lists.php.net
For additional commands, e-mail: php-general-help@li­sts.php.net
To contact the list administrators, e-mail: php-list-admin@list­s.php.net

Add comment
Thomas Deliduka 26 June 2000 19:11:05 permanent link ]
 I found it interesting that on 6/26/00 11:59 AM Jason Stechschulte said:
And there really is no echo in front of the first $row["id"]. The problem> that you are describing is different. I have no idea why you are having> that problem. You might be better off posting to the developer list.

I'll get on that then. Perhaps I'll get a good answer. :-)­
--

Thomas Deliduka
IT Manager
-------------------­------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.c­om/


Add comment
Gabor Gludovatz 26 June 2000 20:41:39 permanent link ]
 On Mon, 26 Jun 2000, Jason Stechschulte wrote:
There is no echo in front of the first $row["id"].

aargh, in my original version the echo is there... but it doesn't work.

--
Gabor Gludovatz <ggabor@sopron.hu> http://www.sopron.h­u/~ggabor/
"Microsoft shouldn't be broken up. It should be shut down."

Add comment
Thomas Deliduka 26 June 2000 20:47:34 permanent link ]
 I found it interesting that on 6/26/00 1:41 PM Gabor Gludovatz said:
There is no echo in front of the first $row["id"].>
aargh, in my original version the echo is there... but it doesn't work.

I just found out from the Dev list that this will be fixed in version 4.0.1

A work-around is: echo "http://www.whole domain/blah.php3?fi­le=$row["id"]&"
. $SID;

--

Thomas Deliduka
IT Manager
-------------------­------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.c­om/


Add comment
Peter Van Dijck 26 September 2000 16:52:53 permanent link ]
 I'm having a weird problem with php4 sessions:
if I turn my cookies off, (the page uses frames), some of the frames (which
all use sessions in some ways) give me a page not found error? If I turn
cookies back on error is gone??
I haven't got a clue....
Peter

Add comment
Ben 18 April 2001 13:38:45 permanent link ]
 i'm trying to use sessions with my project, but it seems that registered
variables in a session aren't global by default.
It doesn't even seem like the session is global, because if I reference the
sessionid (which only shows up if cookies are disabled)
by using <?=SID?>, it shows up within a function, if I reference it from
within the function.

if anyone can help me make my variables (such as $user, and $active)
globally registered with the session, I would be very grateful.
maybe its the cookie not being global, that would explain why the sessionid
shows up only from within a function (but not in the global scope)

thanks
ben
ben@nyip.net



Add comment
Plutarck 18 April 2001 15:42:42 permanent link ]
 Rather than bothering with SID whos existance is uncertain, use the variable
$PHPSESSID. It's set whenever you use session_start, to my knowledge.

The simplest method, and the only one I am aware of, of accessing session
variables globally is by explicitly declaring them global in your function.
It's also the best way to do it, as it may take extra typing when declaring
your function, but it makes it alot more readable and bug-free.


--
Plutarck
Should be working on something...
...but forgot what it was.


""Ben"" <ben@nyip.net> wrote in message
news:9bjn4n$41c$1@t­oye.p.sourceforge.ne­t...> i'm trying to use sessions with my project, but it seems that registered> variables in a session aren't global by default.> It doesn't even seem like the session is global, because if I reference
sessionid (which only shows up if cookies are disabled)> by using <?=SID?>, it shows up within a function, if I reference it
from> within the function.>
if anyone can help me make my variables (such as $user, and $active)> globally registered with the session, I would be very grateful.> maybe its the cookie not being global, that would explain why the
sessionid> shows up only from within a function (but not in the global scope)>
thanks> ben> ben@nyip.net>
--> PHP General Mailing List (http://www.php.net­/)> To unsubscribe, e-mail: php-general-unsubsc­ribe@lists.php.net> For additional commands, e-mail: php-general-help@li­sts.php.net> To contact the list administrators, e-mail: php-list-admin@list­s.php.net>


Add comment
Jon Yaggie 16 July 2001 18:12:48 permanent link ]
 i have three pages all begin with session_start() one fo the variables i register on the first page si $directory which is used to create a unique and temp directory for user files. in the first this is some stuff saved tot his directory. in the second page there is information pulled fromt this directory. in the third when i try to save to it i get the following erros


Warning: fopen("/body.html",­"a+") - Permission denied in /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 35

Warning: Supplied argument is not a valid File-Handle resource in /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 36

Warning: Supplied argument is not a valid File-Handle resource in /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 37

from the code

$pg_info .= "</table>";
$file = "$directory/body.ht­ml";
$handle = fopen($file, "a+");
fputs($handle, $pg_info);
fclose($handle);

as you can see in the error $directory appears not to be there. i didnt unregister it. i didnt change it. where did it go? and what might have cause this??



Thank You,

Jon Yaggie
www.design-monster.­com

And they were singing . . .

'100 little bugs in the code
100 bugs in the code
fix one bug, compile it again
101 little bugs in the code

101 little bugs in the code . . .'

And it continued until they reached 0


Add comment
Scott 16 July 2001 19:05:50 permanent link ]
 any number of things could happen to the $directory variable...
it could be out of scope, gotten overwritten or unset by another
function, or it might just never have been saved to the database...

but the real problem with that code is that there are no
error checks on the file functions. that is a bad thing.

you should *always* check file operations for errors.
$fp = fopen( ... ) or die("Cannot open");

-----Original Message-----> From: Jon Yaggie [mailto:dmsales@design-monster.com]> Sent: Monday, July 16, 2001 10:13 AM> To: php-general@lists.p­hp.net> Subject: [PHP] sessions . . . .>
i have three pages all begin with session_start() one fo the variables i > register on the first page si $directory which is used to create a unique > and temp directory for user files. in the first this is some stuff saved > tot his directory. in the second page there is information pulled fromt > this directory. in the third when i try to save to it i get the following erros>
Warning: fopen("/body.html",­"a+") - Permission denied in > /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 35>
Warning: Supplied argument is not a valid File-Handle resource in > /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 36>
Warning: Supplied argument is not a valid File-Handle resource in > /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 37>
from the code>
$pg_info .= "</table>";> $file = "$directory/body.ht­ml";> $handle = fopen($file, "a+");> fputs($handle, $pg_info);> fclose($handle);>
as you can see in the error $directory appears not to be there. i didnt > unregister it. i didnt change it. where did it go? and what might have > cause this??>
Thank You,>
And they were singing . . . >
'100 little bugs in the code> 100 bugs in the code> fix one bug, compile it again> 101 little bugs in the code>
101 little bugs in the code . . .'>
And it continued until they reached 0>
Add comment
Jon Yaggie 16 July 2001 19:11:22 permanent link ]
 Luiz

I can see from the error message the variable is empty in control.php.
however there are two pages of script before it where it does exist. So
the problem is why isnt it also available in this part of the script? i
have started the session on this page also which should make it avaiable. i
do register more variables on this page but i never reregister $directory




Thank You,

Jon Yaggie
www.design-monster.­com

And they were singing . . .

'100 little bugs in the code
100 bugs in the code
fix one bug, compile it again
101 little bugs in the code

101 little bugs in the code . . .'

And it continued until they reached 0


----- Original Message -----
From: "Luiz Vitor" <lvdamin@terra.com.­br>
To: "Jon Yaggie" <dmsales@design-mon­ster.com>
Sent: Monday, July 16, 2001 9:22 PM
Subject: Re: [PHP] sessions . . . .

Probably the $directory variable is empty or incorrect.> Why don't you print $directory variable and see what is the value.>
Regards,> Luiz Vitor>
----- Original Message -----> From: "Jon Yaggie" <dmsales@design-mon­ster.com>> To: <php-general@lists.­php.net>> Sent: Monday, July 16, 2001 11:12 AM> Subject: [PHP] sessions . . . .>
i have three pages all begin with session_start() one fo the variables i> register on the first page si $directory which is used to create a unique> and temp directory for user files. in the first this is some stuff saved> tot his directory. in the second page there is information pulled fromt> this directory. in the third when i try to save to it i get the following> erros>
Warning: fopen("/body.html",­"a+") - Permission denied in> /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 35>
Warning: Supplied argument is not a valid File-Handle resource in> /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 36>
Warning: Supplied argument is not a valid File-Handle resource in> /home/www/hvacsites­.com/SiteBuilder/con­trol.php on line 37>
from the code>
$pg_info .= "</table>";> $file = "$directory/body.ht­ml";> $handle = fopen($file, "a+");> fputs($handle, $pg_info);> fclose($handle);>
as you can see in the error $directory appears not to be there. i didnt> unregister it. i didnt change it. where did it go? and what might have> cause this??>
Thank You,>
And they were singing . . .>
'100 little bugs in the code> 100 bugs in the code> fix one bug, compile it again> 101 little bugs in the code>
101 little bugs in the code . . .'>
And it continued until they reached 0>

Add comment
Jeremy Morano 17 August 2001 22:29:04 permanent link ]
 Hi there, I was wondering if a function such as session_close() or
session_stop() existed. You see, i've been using session_destroy and/or
session_unregister but the problem is that they unregister and/or destroy
ALL my sessions in my server folder. What I am trying to do is just stop the
session that is going on in that particular page? How can I do this?

Add comment
Rob Hardowa 17 August 2001 23:16:27 permanent link ]
 Hi Jeremy,

session_destroy() should not destroy all your sessions. As per the manual:

session_destroy() destroys all of the data associated with the current
session.

If you are having trouble with all your sessions being deleted in each run,
it may be a problem with these php.ini file settings:

session.gc_probabil­ity specifies the probability that the gc (garbage
collection) routine is started on each request in percent. Defaults to 1.

session.gc_maxlifet­ime specifies the number of seconds after which data will
be seen as 'garbage' and cleaned up.

You can find all the php session info at:
http://php.net/manu­al/en/html/ref.sessi­on.html


On Friday 17 August 2001 11:29 am, you wrote:> Hi there, I was wondering if a function such as session_close() or> session_stop() existed. You see, i've been using session_destroy and/or> session_unregister but the problem is that they unregister and/or destroy> ALL my sessions in my server folder. What I am trying to do is just stop> the session that is going on in that particular page? How can I do this?
Add comment
Jeremy Morano 21 August 2001 23:57:52 permanent link ]
 Hi ,

I'm having problems with my session_unregister(­). Maybe what i'm trying to
do can't be done but I would like someones opinion. This is what I am doing
and why i'm doing it.

session_start();
session_unregister(­val_1);
session_register(va­l_1);

I am doing this to clear the contents of val_1 before I use it again.
Needless to say its not working. val_1 always contains the same value until
I close the browser. How should I go about it?


P.S. Sorry if you've seen a similar post yesterday, I just never got a
reply.

Add comment


Kirk Johnson 22 August 2001 00:01:25 permanent link ]
 
session_start();> session_unregister(­val_1);> session_register(va­l_1);>
I am doing this to clear the contents of val_1 before I use it again.> Needless to say its not working. val_1 always contains the > same value until

session_registering­()'ing a variable just puts it in a list of names of the
session variables. session_unregister(­) just removes the name from the list.
Neither function affects the variable's value.

To clear the variable's value, just assign it to blank, or call unset() on
it, e.g.,

$val_1 = "";
unset($val_1);

There is no need, or use, in unregistering it, then registering it again.

Kirk
Add comment
Anthony 11 December 2001 19:53:33 permanent link ]
 I need some help with sessions. I read the sections in the manual and
searched for tutorials, but I still can't get a straight forward example
of how sessions work. I need to pass variables to a page that will load
in a new browser window. I used session_register, but when I look in
the $HTTP_SESSION_VARS,­ it doesn't exist. I tried using start_session
and still no luck. Once I get the session vars registered, how do I
access them. I am able to pass the session id as a var, I'm going it
like page.php?sid=$<sid_­var>. Is there a better way, do I need to do
this at all? I'm confused as hell and can't find a working example
anywhere. Help!

- Anthony

Add comment


Anthony 11 December 2001 20:32:33 permanent link ]
 thanks for the starter. I have session.use_trans_s­id = 1 in my php.ini,
I also have session_start() at the beginning of both pages. Now
$HTTP_SESSION_VARS is there, but its a blank array.
print_r($HTTP_SESSI­ON_VARS); yields-> Array ( )
the code I have at one page is
$z=<some data>;
session_start();
session_register('$­z');
I also tried without the quotes, still a blank array. What am I doing
wrong? How do I make sure I'm starting the correct session in the new
page? I can get the session ID, but what do I do with it?



Steffan Packer wrote:
You need to have>
session_start();>
at the top of each page that needs to use the session vars, also check that> session.use_trans_s­id is set to 1 in your ini file> hope this helps!>
-----Original Message-----> From: Anthony [mailto:atampone@attechcomputer.com]> Sent: Tuesday, December 11, 2001 3:54 PM> To: php-general@lists.p­hp.net> Subject: [PHP] sessions>
I need some help with sessions. I read the sections in the manual and > searched for tutorials, but I still can't get a straight forward example > of how sessions work. I need to pass variables to a page that will load > in a new browser window. I used session_register, but when I look in > the $HTTP_SESSION_VARS,­ it doesn't exist. I tried using start_session > and still no luck. Once I get the session vars registered, how do I > access them. I am able to pass the session id as a var, I'm going it > like page.php?sid=$<sid_­var>. Is there a better way, do I need to do > this at all? I'm confused as hell and can't find a working example > anywhere. Help!>
- Anthony>

Add comment
Anthony 11 December 2001 21:06:29 permanent link ]
 Thank you very much, I got it to work. What I didn't understand was
that when registering the session var I was not registering the var's
value, only the pointer. This makes all kinds of sence now. Thanks!

- Anthony

Steffan Packer wrote:
You need to have>
session_start();>
at the top of each page that needs to use the session vars, also check that> session.use_trans_s­id is set to 1 in your ini file> hope this helps!>
-----Original Message-----> From: Anthony [mailto:atampone@attechcomputer.com]> Sent: Tuesday, December 11, 2001 3:54 PM> To: php-general@lists.p­hp.net> Subject: [PHP] sessions>
I need some help with sessions. I read the sections in the manual and > searched for tutorials, but I still can't get a straight forward example > of how sessions work. I need to pass variables to a page that will load > in a new browser window. I used session_register, but when I look in > the $HTTP_SESSION_VARS,­ it doesn't exist. I tried using start_session > and still no luck. Once I get the session vars registered, how do I > access them. I am able to pass the session id as a var, I'm going it > like page.php?sid=$<sid_­var>. Is there a better way, do I need to do > this at all? I'm confused as hell and can't find a working example > anywhere. Help!>
- Anthony>

Add comment


Chris Lee 18 December 2001 21:33:59 permanent link ]
 take a look at my session.egn file.

http://www.mediawav­eonline.com/examples­/

--

Chris Lee
lee@mediawaveonline­.com



"Anthony" <atampone@attechcom­puter.com> wrote in message
news:3C162BFD.60908­06@attechcomputer.co­m...> I need some help with sessions. I read the sections in the manual and> searched for tutorials, but I still can't get a straight forward example> of how sessions work. I need to pass variables to a page that will load> in a new browser window. I used session_register, but when I look in> the $HTTP_SESSION_VARS,­ it doesn't exist. I tried using start_session> and still no luck. Once I get the session vars registered, how do I> access them. I am able to pass the session id as a var, I'm going it> like page.php?sid=$<sid_­var>. Is there a better way, do I need to do> this at all? I'm confused as hell and can't find a working example> anywhere. Help!>
- Anthony>


Add comment
Daniel Masur 21 December 2001 11:56:15 permanent link ]
 my logout.php looks like this

<code>
session_start();
session_register("S­ESSION"); //these 2 things have to be on every page
right?
require ('validate_session.­php'); //does compare $PHPSESSID and the sessid i
have in every url

// start of validate_session.ph­p
<?
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modifi­ed: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Contr­ol: no-store, no-cache, must-revalidate");
header("Cache-Contr­ol: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

if($id != $PHPSESSID)
{
session_destroy();
setcookie ("cookie", "", time() - 32436000);
echo"<SCRIPT LANGUAGE=\"JavaScri­pt\"><!--\n document.location.h­ref =
'/test/auth.php'; \n /--></script>";
exit;
}
?>
// end of validate_session.ph­p

session_destroy();
session_unregister(­"SESSION");
session_unset("SESS­ION");
session_write_close­();
</code>

but the session wont leave. i can browse to other sides, but i can comeback
later, and i get the same session id...

what is wrong?



Add comment
Alexander P. Javier 24 February 2002 07:36:43 permanent link ]
 ok, i got i working now, thanx to all who helped especially michael, chris & edward

alyx



-------------------­--------------
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
Add comment
Joshua E Minnie 21 March 2002 01:05:42 permanent link ]
 I am kind of confused by an error I am getting when trying to destroy a
session. Here is the error that I am receiving along with the code that is
causing the problem.

Warning: Cannot send session cache limiter - headers already sent (output
started at /home/www/wildwebte­ch/cumc/default.php:­9) in
/home/www/wildwebte­ch/cumc/default.php on line 10

<?
session_start();

$old_user = $cumc_user; // store to test if they *were* logged in
$result = session_unregister(­"cumc_user");
session_destroy();
?>

This is the only code on that particular page, I just want to make sure that
when they leave the site via my links that the session is destroyed.

--
Joshua E Minnie
CIO
josh@acsurf.net

"Don't work for recognition, but always do work worthy of recognition."


Add comment
Alastair Battrick 21 March 2002 01:24:36 permanent link ]
 There must be some whitespace in the script before the opening <?php

Lose that and the error should go with it.

Alastair Battrick
Senior Developer
Lightwood Consultancy Ltd
http://www.lightwoo­d.net
I am kind of confused by an error I am getting when trying to destroy a> session. Here is the error that I am receiving along with the > code that is> causing the problem.>
Warning: Cannot send session cache limiter - headers already sent (output> started at /home/www/wildwebte­ch/cumc/default.php:­9) in> /home/www/wildwebte­ch/cumc/default.php on line 10>
<?> session_start();>
$old_user = $cumc_user; // store to test if they *were* logged in> $result = session_unregister(­"cumc_user");> session_destroy();>­ ?>

Add comment
Jason Wong 2 April 2002 22:18:55 permanent link ]
 On Wednesday 03 April 2002 21:34, R. Lindeman wrote:> i have a problem with PHP sessions and maybe some of you could help what do> i need in my php.ini to get them to work !!!

You just need to edit it until it works.


Seriously, if you're going to keep your problem a secret nobody will be able
to help you.

*What* problems are you having with your sessions?


--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk­

/*
It's a funny thing that when a woman hasn't got anything
on earth to worry about, she goes off and gets married.
*/
Add comment
Jason Wong 3 April 2002 00:19:16 permanent link ]
 On Thursday 04 April 2002 01:04, R. Lindeman wrote:> okay i'll explain a bit>
i want my sessions to store some values but instead of storing them their> doing nothing at all here's some code>
// beginning of registering of values>
session_start();>
session_register("f­u");> session_register("b­ar");>
$fu = "fu";> $bar = "bar";>
// end of registering values>
//getting values>
$fu = $HTTP_SESSION_VARS["fu"];­>
echo $fu;>
//end of getting values

If you are using PHP > 4.06 then try:

$fu = $_COOKIE["fu"];

--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk­

/*
What I want to find out is -- do parrots know much about Astro-Turf?
*/
Add comment
Jason Wong 3 April 2002 00:29:35 permanent link ]
 On Wednesday 03 April 2002 04:19, Jason Wong wrote:> On Thursday 04 April 2002 01:04, R. Lindeman wrote:> > okay i'll explain a bit> >
i want my sessions to store some values but instead of storing them their> > doing nothing at all here's some code> >
// beginning of registering of values> >
session_start();> >
session_register("f­u");> > session_register("b­ar");> >
$fu = "fu";> > $bar = "bar";> >
// end of registering values> >
//getting values> >
$fu = $HTTP_SESSION_VARS["fu"];­> >
echo $fu;> >
//end of getting values>
If you are using PHP > 4.06 then try:>
$fu = $_COOKIE["fu"];

Hmm, are you setting and reading the cookie on the same page? If so, it can't
be done. You need to either set it on one page then read on another, or set
it then refresh the page.




--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk­

/*
It doesn't much signify whom one marries, for one is sure to find out
next morning it was someone else.
-- Will Rogers
*/
Add comment
R. Lindeman 3 April 2002 17:34:44 permanent link ]
 i have a problem with PHP sessions and maybe some of you could help what do
i need in my php.ini to get them to work !!!


Add comment
R. Lindeman 3 April 2002 21:04:58 permanent link ]
 okay i'll explain a bit

i want my sessions to store some values but instead of storing them their
doing nothing at all here's some code

// beginning of registering of values

session_start();

session_register("f­u");
session_register("b­ar");

$fu = "fu";
$bar = "bar";

// end of registering values

//getting values

$fu = $HTTP_SESSION_VARS["fu"];­

echo $fu;

//end of getting values






"R. Lindeman" <rlindeman@filenexu­s.com> wrote in message
news:20020402153536­.66126.qmail@pb1.pai­r.com...> i have a problem with PHP sessions and maybe some of you could help what
i need in my php.ini to get them to work !!!>


Add comment
Mike Fifield 26 April 2002 18:57:21 permanent link ]
 Is there a way to return the total number of sessions currently registered
on a server?


Add comment
Miguel Cruz 26 April 2002 19:00:18 permanent link ]
 On Fri, 26 Apr 2002, Fifield, Mike wrote:> Is there a way to return the total number of sessions currently registered> on a server?

You could count the files in the session store directory.

miguel


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


Add comment
Jan Peuker 26 April 2002 19:02:44 permanent link ]
 If you use files you might get the contens of the folder where sessions
stored and just count.

Jan
----- Original Message -----
From: "Fifield, Mike" <Mike.Fifield@schwa­b.com>
To: <php-general@lists.­php.net>
Sent: Friday, April 26, 2002 5:57 PM
Subject: [PHP] sessions

Is there a way to return the total number of sessions currently registered> on a server?>


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


Add comment
Jas 13 May 2002 03:30:17 permanent link ]
 I am a little confused on how to keep a variable registered on more than one
page. For example you log into a page which queries the database. Form
code is as follows...
<?php
session_start();
?>
<html>
<body bgcolor="#FFFFFF" text="#000000">
<?php print(session_id())­; ?>
<form name="login" method="post" action="auth_done.p­hp">
User Name:
<input type="text" name="u_name" maxlength="25">
Password:
<input type="password" name="p_word" maxlength="25">
<input type="submit" name="login" value="login">
</form>
</body>
</html>
The auth_done.php then checks to see if the user entered anything for the
username and password and if it doesnt it will re-direct them to the login
page. If the un and pw has been entered it will then query the database for
a valid entry, code is as follows...
<?php
if ((!$u_name) || (!$p_word)){
header("Location: index.php");
exit;
}
$db_name = "authentication";
$table_name = "accounts";
$connection = @mysql_connect("loc­alhost","","") or die("Could not connect to
Database, please try again later");
$db = @mysql_select_db($d­b_name, $connection) or die("Could not select
Database, please try again later");
$sql = "SELECT * from $table_name
WHERE u_name = \"$u_name\" AND p_wordd = password(\"$p_word\­")";
$result = @mysql_query($sql,$­connection) or die("Couldn't execute query");
$num = mysql_numrows($resu­lt);
if ($num !=0) {
$msg = "<p class=\"content\">Y­ou have been authorized to make changes to the
web site.</p>";
session_is_register­ed('u_name');
session_is_register­ed('p_word');
session_start();
} else {
header("Location: index.php");
exit;
}
?>
<html>
<body bgcolor="#FFFFFF" text="#000000">
<?php echo $msg; ?><br>
<?php print (session_id()); ?><br>
<?php echo $u_name; ?><br>
<?php echo $p_word; ?><br>
<?php print (session_is_registe­red('u_name')); ?><br>
<?php print (session_is_registe­red('p_word')); ?><br>
<a href="edit.php">edi­t pages</a>
</body>
</html>
The problem I am having is if the user clicks the link for edit.php the
session variables "u_name" and "p_word" are not being passed and I can't do
any other checking with out that. Please help, good tutorials on this are
very appreciated!
Thanks in advance,
Jas



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


Add comment
Chris Knipe 13 May 2002 04:27:54 permanent link ]
 Ok,

Let's see if I learned anything....


----- Original Message -----
From: "Jas" <jlgerfen@hotmail.c­om>
To: <php-general@lists.­php.net>
Sent: Monday, May 13, 2002 2:30 AM
Subject: [PHP] sessions


<SNIP>> $msg = "<p class=\"content\">Y­ou have been authorized to make changes to
web site.</p>";> session_is_register­ed('u_name');> session_is_register­ed('p_word');

$_SESSION['u_name'] = $u_name;
$_SESSION['p_word'] = $p_word;
session_start();

^^ Not to sure if you need this again, I doub't it.
} else {> header("Location: index.php");> exit;> }> ?>> <html>> <body bgcolor="#FFFFFF" text="#000000">> <?php echo $msg; ?><br>> <?php print (session_id()); ?><br>> <?php echo $u_name; ?><br>> <?php echo $p_word; ?><br>> <?php print (session_is_registe­red('u_name')); ?><br>> <?php print (session_is_registe­red('p_word')); ?><br>

print ($_SESSION['u_name']);
print ($_SESSION['p_word']);



Syntax has not been double checked, so there might be a few errors, but you
should be using $_SESSION['varname']; :)­

See, I actually do learn things aswell over time :)­ Thanks again for
everyone who has helped me!!! My next set of questions will prob be on
GDLib (I can feel this coming)...

--
me




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


Add comment
Blue Presley 17 May 2002 09:08:58 permanent link ]
 I'm using php 4.2 with transparent session id enables. I'm having trouble getting the session id to append the url of my subsequent pages after the session has started. within normal php pages, the SID is automatically attached to the url, but using it through smarty this is not happening.

I've tried something like $smarty->assign("se­ssid", session_id()) but i'm not getting the variables to pass correctly.

anyone else out there correctly using sessions and smarty? thanks in advance for your help.

blue
Add comment
Ivo Jansch 17 May 2002 10:55:53 permanent link ]
 Hi,

Blue Presley wrote:
anyone else out there correctly using sessions and smarty? thanks in advance for your help.

I am using it. But I don't see how this can be caused by Smarty. Smarty
doesn't do anything with links at all. Are you using SID in your urls to
automatically append the session_id, or are you doing this manually?

Greetings,
Ivo

--
Ivo Jansch <ivo@ibuildings.nl>­
ibuildings.nl BV - information technology
http://www.ibuildin­gs.nl



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


Add comment
Jason Sweat 17 May 2002 14:26:23 permanent link ]
 most of my links are back to the script itself (I tend to contain everything
related to a given application in a single file). I use the following
function like this:
$t->assign('SELFLIN­K',phpself());


/**
* return a url to the current script, caring about the sid if defined
*
* @author Jason E. Sweat
* @since 2002-04-07
* @return string the php_self url
*/
function phpself()
{
global $sid;

$protocol = 'http';

if (443 == $_SERVER['SERVER_PORT']) {
$protocol .= 's';
}

$ret = $protocol.'://'.$_S­ERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?';

if (isset($sid)) {
$ret .= "sid={$sid}&";
}

return $ret;
}


----- Original Message -----
From: "Blue Presley" <blue928@carolina.r­r.com>
To: <smarty-general@lis­ts.php.net>
Sent: Friday, May 17, 2002 1:08 AM
Subject: [SMARTY] sessions


I'm using php 4.2 with transparent session id enables. I'm having trouble
getting the session id to append the url of my subsequent pages after the
session has started. within normal php pages, the SID is automatically
attached to the url, but using it through smarty this is not happening.

I've tried something like $smarty->assign("se­ssid", session_id()) but i'm
not getting the variables to pass correctly.

anyone else out there correctly using sessions and smarty? thanks in advance
for your help.

blue



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


Add comment
Jason Sweat 17 May 2002 17:17:38 permanent link ]
 
Actually I am not. Try it. The curly braces inside
of a quoted string identify the variable for
replacement.

You are usng smarty tags inside your PHP code
if (isset($sid)) {> $ret .= "sid={$sid}&";


___________________­____________________­___________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo­.com

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


Add comment
James Kupernik 23 May 2002 17:38:04 permanent link ]
 I get this error when I try to start a session (I'm trying to create a
shopping cart).

Warning: Cannot send session cache limiter - headers already sent


Thanks



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


Add comment
Matt Stewart 23 May 2002 17:41:16 permanent link ]
 sent the session_start(); before any output, that should do it...

-----Original Message-----
From: James Kupernik [mailto:kupernik@bcn.net]
Sent: 23 May 2002 15:38
To: php-db@lists.php.ne­t
Subject: [PHP-DB] sessions


I get this error when I try to start a session (I'm trying to create a
shopping cart).

Warning: Cannot send session cache limiter - headers already sent


Thanks



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

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


Add comment
James Kupernik 23 May 2002 17:47:41 permanent link ]
 Do you know where there is any good tutorials on creating a php shopping
cart?

I enabled the auto.session_start .. then took o