Forums

PHP

This topic is locked

php sessions

Posted 27 Nov 2008 19:57:30
1
has voted
27 Nov 2008 19:57:30 Stefan P posted:
Does a php session also write the details to a cookie. I've found that I also need to destroy a cookie when destroying the session?!?!

Edited by - sesame on 28 Nov 2008 12:29:32

Replies

Replied 28 Nov 2008 12:46:39
28 Nov 2008 12:46:39 Alan C replied:
Hi
My understanding was that you had to explicitly write something to a cookie. If you're using a script that you didn't write then it may be writing a cookie and the code is hidden away somewhere.
Replied 28 Nov 2008 13:42:19
28 Nov 2008 13:42:19 Stefan P replied:
Sorry, getting really confused.

If I set a session, can I call the session variables set in that session from any page on that site? I have set a session variable on one page, but when I call it on another page, it's not working ie seems empty. Not having much luck with guidance on php.net <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>

How do I ensure it persists. (btw, it's not time out)

Cheers

Stefan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DW8 | XHTML | CSS | PHP
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replied 28 Nov 2008 14:27:32
28 Nov 2008 14:27:32 Stefan P replied:
Hmm, seems like you need to start the session on every page. Is that correct?


Stefan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DW8 | XHTML | CSS | PHP
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replied 01 Dec 2008 14:26:24
01 Dec 2008 14:26:24 Alan C replied:
Hi Stephan,

here is a really useful tutorial about sessions and login evolt.org/article/comment/17/60265/index.html

I've put up a quick and dirty session example here alanchard.com/stest/index.php
it is two very small pages, it copies a variable from one page to the next, it uses the time function, so when you get to page two, have a look for the difference between the two time values, it will be however many seconds you waited between viewing page one and hitting the link

Yes, you need to say session start on every page where you want to access the session, my understanding is that the session id gets stored in a cookie somewhere in the background

Hope that helps

Reply to this topic