|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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"> |
|
#3
|
|||
|
|||
|
Quote:
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. |
|
#4
|
|||
|
|||
|
Quote:
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > session_regenerate_id() needs refreshing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|