SitePoint Sponsor |
|
User Tag List
Results 26 to 46 of 46
Thread: PHP Cookies
-
Feb 1, 2001, 14:07 #26
- Join Date
- Aug 2000
- Location
- Land of the long white cloud
- Posts
- 556
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What it really comes down to is assuming cookies can be used is a cardinal sin like building pages just for internet explorer 5.5 ... and i repent
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!
-
Feb 1, 2001, 14:12 #27
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Depeneds really on the user base. If the user base will be largely employees from big corps with big firewalls and no use of cookies allowed, then yes it is something to worry about. But for the most part the average user wouldn't know how to disable cookies if he or she tried
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Feb 1, 2001, 14:28 #28
- Join Date
- Jan 2001
- Location
- buried in the database shell (Washington, DC)
- Posts
- 1,107
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by freddydoesphp
Matt none of these links seem to work. I can't speak for performance I never built a site like amazon where I get millions of hits everyday, but for sites I have built --enable-trans-sid has worked great for the non-cookie users. I will have to take a look at the mod_rewrite for apache and see, but from my experience the only way to insure that the session id gets passed, is to pass it in the url, that is why PHPLIB does that way too.
mod_reqrite is pretty easy:
My example URL:
http://www.bobross.com/session_id/index.php
Can be re-written as:
RewriteEngine ON
RewriteBase /
RewriteRule ^[0-9a-z]{32}/(.+) /$1
(You'd put that in your http.conf file or an .htaccess file.)
Then instead of calling session_start( );, you'd create your own function:
Code:function session_start_from_rewrite( ) { global $HTTP_HOST, $REQUEST_URI; ereg( "/([0-9a-z]{32})", $REQUEST_URI, $regs ); $session_id = $regs[ 1 ]; if( !isset( $session_id ) || empty( $session_id ) ) { srand( (double)microtime( ) * 10000000 ); $session_id = md5( uniqid( rand( ) ) ); $destination = "http://$HTTP_HOST/$session_id$REQUEST_URI"; header( "Location: $destination" ); } // end if session_id( $session_id ); session_start( ); } // end function session_start_from_rewrite
DNS rewrite works much the same way, but with a couple variables changed in the function (and a couple caveats along with it).
But again, the easiest and fastest way for small to medium sites is to simply use PHP to do it -- the only tradeoff is the overhead in PHP generating the page and then looking at each link to re-write it, which can be severe if you have quite a lot of traffic in a short amount of time and/or you have a bazillion links on one page.Matt - Sybase DBA / PHP fanatic
Sybase/MySQL/Oracle | I don't like MySQL
Download Sybase | DBForums.com - for all your RDBMS talk
-
Feb 1, 2001, 14:32 #29
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for the info.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Feb 1, 2001, 15:13 #30
- Join Date
- Oct 1999
- Location
- Vancouver, BC, Canada
- Posts
- 983
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Wouldn't passing the session id in the URL cause a problem if the page were bookmarked?
- A simple online WYSIWYG editor for HTML code snippets.
- Managed Web Hosting - $3.95/month (resellers welcome)
- Why pay more? $8.95 domains & $9.95 SSL certificates!
-
Feb 1, 2001, 16:00 #31
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can't have your cake and eat it too!
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Feb 1, 2001, 16:07 #32
- Join Date
- Jan 2001
- Location
- buried in the database shell (Washington, DC)
- Posts
- 1,107
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by hstraf
Wouldn't passing the session id in the URL cause a problem if the page were bookmarked?
Create a new session using that ID
Create a new session with a new ID and redirect the user as such
or
Ignore the session ID and treat them as logged out.
With a proper session hash (like the one I used), the chances of someone using another person's hash is *very* remote - there are 2^128 (or 340,282,366,920,938,463,463,374,607,431,768,211,456) possible values!Matt - Sybase DBA / PHP fanatic
Sybase/MySQL/Oracle | I don't like MySQL
Download Sybase | DBForums.com - for all your RDBMS talk
-
Feb 2, 2001, 11:47 #33
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for your help guys
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
Feb 5, 2001, 10:04 #34
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
mad-onion...back to yuor mktime post.
If i change the date ..how do I also ge tthe time?
coz if i just change the date and compare, that would mean only the date..
how do i compare the date and time?
Add the timestamp for date and time together?
Thanks"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
Feb 5, 2001, 14:31 #35
- Join Date
- Aug 2000
- Location
- Land of the long white cloud
- Posts
- 556
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A timestamp is unique for the second. So you probably dont need it any more accurate than seconds.
Does that answer your question?SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!
-
Feb 5, 2001, 22:21 #36
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry..I'm not too sure what you're saying
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
Feb 6, 2001, 12:26 #37
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
mktime produces a numeric value unique to that second - IE: if you load the page once, and then a second later, the two numbers will be different...conflicts will arrive if two people visit at once, though, so you might want to use something else.
That right, or am I way off?
-
Feb 6, 2001, 13:19 #38
- Join Date
- Aug 2000
- Location
- Land of the long white cloud
- Posts
- 556
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yip thats right commish, atleast ive always thought thats what it is.
A side note...
It is actually the number of seconds since Midnight January 1 1970 or something near there.SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!
-
Feb 6, 2001, 13:26 #39
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yup, I think that's the exact date - dunno why!
Is there some way to convert the value to a normal date?
-
Feb 6, 2001, 13:50 #40
- Join Date
- Aug 2000
- Location
- Land of the long white cloud
- Posts
- 556
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yip, using the date function..you feed it the desired format and an optional timestamp and it spews out the date in the format you desire.
There are heaps of letters you can use to define the format of the outputted date.
Take a look at the date function in the php manual.SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!
-
Feb 6, 2001, 13:56 #41
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh yeah, I've seen that - just wasn't very good with using it in conjunction with the mktime() function - I have a copy of vBulletin and wanted to find out which days in it's history had the most posts, but all I have are a bunch of UNIX timestamps.
-
Feb 6, 2001, 13:59 #42
- Join Date
- Aug 2000
- Location
- Land of the long white cloud
- Posts
- 556
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh yeah, timestamps are the best way to store a date in a db or whatever.
You would actually convert it manually if you so desired..SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!
-
Feb 6, 2001, 14:02 #43
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh yeah, that would be fun.
I just like to have "Board Records" and such - most posts in a day, most members signed up in a day, etc. Unfortunatly, I just can't figure out how to calculate the first.
-
Feb 10, 2001, 12:45 #44
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
I have another query regarding cookies/
If I set the expire time to be 24 hours, which would be : time()+(3600*24)
after 24 hours, if i use
if (isset($cookie)) { cookie exists }
else { setcookie(); }
will it still work?
will the cookie still return 1?"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
Feb 10, 2001, 13:03 #45
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No, I don't believe so - once a cookie is expired, I'm fairly sure it is is discarded as if it never existed in the first place.
You can test it out by setting the expiration to one minute.
-
Feb 10, 2001, 21:24 #46
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Alright
Thanks for your help."Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
Bookmarks