PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 8th, 2004, 08:16 PM
devey devey is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 9 devey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
session_regenerate_id() needs refreshing

I have this code to create a function to generate a generate a cookie
based on session_id:

session_start();
session_regenerate_id();
session_register();
setcookie("cartId", session_id());
return session_id();
}


It is then set to $_COOKIE["cartId"]; which is used to generate a cookie
id in the database to track items etc.

I have included the session_regenerate_id(); because i need to create
a new session number if $_COOKIE["cartId"]; is not set which a log out
page i have created unsets it. It works just how i want it to exceot for one
major problem. When i go to the cart page for first time after adding an item
to it doesn't show but it will if i refresh the page.

any advice much appreciated

Reply With Quote
  #2  
Old August 9th, 2004, 03:21 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 997 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 14 h 26 m 27 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
It may be just some bad caching on the part of your browser, try adding this code to the <head> segment:

<meta http-equiv="expires" content="-1">

Reply With Quote
  #3  
Old August 9th, 2004, 10:18 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Quote:
Originally Posted by devey
When i go to the cart page for first time after adding an item
to it doesn't show but it will if i refresh the page.

any advice much appreciated

A session must be created on request ahead of time. Usually you would want to create a session, then redirect to the next page (which would be the cart page).
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #4  
Old August 9th, 2004, 02:35 PM
devey devey is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 9 devey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by laidbak
A session must be created on request ahead of time. Usually you would want to create a session, then redirect to the next page (which would be the cart page).
Yep thanks, i got my head around it sometime this morning lol. The solution i used was to use this code in the redirect page once an order had been accepted:

setcookie("cartId",session_id(), time() - 6000);
session_start();
session_regenerate_id();
session_register();
setcookie("cartId", session_id());
header ("location:stamps.php");

this removes the current cookie cartId, regenerates the session id sets the cookie using the new session id and returns user to the home page. Now once they get to the cart the cookie "cartId" is already set so no refresh needed.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > session_regenerate_id() needs refreshing


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT