PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 18th, 2000, 03:14 AM
Stephane Stephane is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 3 Stephane User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
To check if it exists, I do

$id = session_id();
if ($id == '') {... no session ...}

If the $id is empty, then there is no session.

But the problem is when I use the "session_id()" function from a different page than the page that contains the "session_start()" function, the returned $id is always empty.

Do have I to pass the SID in the url or something? Is there a setup file that I should update?


Reply With Quote
  #2  
Old May 18th, 2000, 08:44 AM
Vinay Vinay is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 10 Vinay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the concept is to not look for an existing session but to look for an existing session variable... try the following:

file page1.php
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<?
session_start();
session_register("isregistered");
$isregistered = 1;
?>
<a href="page2.php?<?=SID?>">click here</a>
[/code]

file page2.php
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<?
session_start();
if(session_is_registered("isregistered")){echo "THE SESSION EXISTS !!!";}
else{echo "NO SESSION, BOO HOO";}
?>
[/code]

hope that helps

--------------------
Kryogen WebHosting - the best for PHP4

Reply With Quote
  #3  
Old May 18th, 2000, 12:35 PM
Stephane Stephane is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 3 Stephane User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I just forgot to use the session_start() function. Now things work wonders!
Thanks!



Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > How to check if a session exists in PHP4?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap